CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-react-error-overlay

An overlay for displaying stack frames and error messages in React development environments.

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

error-reporting.mddocs/

Error Reporting

Core error reporting functionality for monitoring and displaying runtime errors and build errors in the React Error Overlay.

Capabilities

Start Runtime Error Reporting

Begins automatic monitoring of runtime errors, unhandled promise rejections, and console errors.

/**
 * Starts automatic runtime error reporting with configurable options
 * @param options - Configuration object with error callback and optional filename
 * @throws Error if already listening for errors
 */
function startReportingRuntimeErrors(options: RuntimeReportingOptions): void;

interface RuntimeReportingOptions {
  /** Callback function executed when an error is detected and processed */
  onError: () => void;
  /** Optional filename for source mapping, defaults to '/static/js/bundle.js' */
  filename?: string;
  /** @deprecated launchEditorEndpoint is no longer supported. Use setEditorHandler instead. */
  launchEditorEndpoint?: string;
}

Usage Examples:

import { startReportingRuntimeErrors } from "react-error-overlay";

// Basic error reporting
startReportingRuntimeErrors({
  onError: () => {
    console.log('An error occurred and is being displayed');
  }
});

// With custom filename for source mapping
startReportingRuntimeErrors({
  onError: () => {
    // Handle error detection
    analytics.track('development_error_detected');
  },
  filename: '/static/js/main.bundle.js'
});

Stop Runtime Error Reporting

Stops automatic error monitoring and cleans up event listeners.

/**
 * Stops runtime error reporting and removes all error listeners
 * @throws Error if not currently listening for errors
 */
function stopReportingRuntimeErrors(): void;

Usage Examples:

import { 
  startReportingRuntimeErrors, 
  stopReportingRuntimeErrors 
} from "react-error-overlay";

// Start error reporting
startReportingRuntimeErrors({
  onError: () => console.log('Error detected')
});

// Later, stop error reporting (e.g., when switching to production mode)
try {
  stopReportingRuntimeErrors();
  console.log('Error reporting stopped');
} catch (error) {
  console.log('Error reporting was not active');
}

Report Runtime Error

Manually reports a specific runtime error to be displayed in the overlay.

/**
 * Manually reports a runtime error for display in the overlay
 * @param error - JavaScript Error object to report
 * @param options - Optional configuration object
 */
function reportRuntimeError(
  error: Error, 
  options?: RuntimeReportingOptions
): void;

Usage Examples:

import { reportRuntimeError } from "react-error-overlay";

// Report a caught error
try {
  riskyOperation();
} catch (error) {
  reportRuntimeError(error, {
    onError: () => {
      console.log('Manually reported error is displayed');
    }
  });
}

// Report a custom error
const customError = new Error('Something went wrong in data processing');
customError.stack = getCustomStackTrace();
reportRuntimeError(customError);

Report Build Error

Reports compilation or build errors to be displayed in the overlay.

/**
 * Reports a build/compilation error for display in the overlay
 * @param error - String containing the formatted build error message
 */
function reportBuildError(error: string): void;

Usage Examples:

import { reportBuildError } from "react-error-overlay";

// Report webpack compilation error
const webpackError = `
Module build failed: SyntaxError: Unexpected token (15:4)

  13 |   return (
  14 |     <div>
> 15 |       <p>Hello World</p
  16 |     </div>
  17 |   );
  18 | }
`;

reportBuildError(webpackError);

// Report TypeScript error
const tsError = `
TypeScript error in /src/components/Button.tsx(12,5):
Type 'string' is not assignable to type 'number'.
`;

reportBuildError(tsError);

Error Deduplication

The error reporting system automatically deduplicates identical errors to prevent spam:

// These will only show once, even if the same error occurs multiple times
const error = new Error('Duplicate error');
reportRuntimeError(error);
reportRuntimeError(error); // Deduplicated - won't show again
reportRuntimeError(error); // Deduplicated - won't show again

Types

interface RuntimeReportingOptions {
  /** Callback function executed when an error is detected and processed */
  onError: () => void;
  /** Optional filename for source mapping, defaults to '/static/js/bundle.js' */
  filename?: string;
  /** @deprecated launchEditorEndpoint is no longer supported. Use setEditorHandler instead. */
  launchEditorEndpoint?: string;
}

Install with Tessl CLI

npx tessl i tessl/npm-react-error-overlay

docs

editor-integration.md

error-dismissal.md

error-reporting.md

index.md

tile.json