react#ErrorInfo TypeScript Examples

The following examples show how to use react#ErrorInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: apiPostError.ts    From caritas-onlineBeratung-frontend with GNU Affero General Public License v3.0 6 votes vote down vote up
apiPostError = async (
	error: ErrorBoundaryError,
	info: ErrorInfo
): Promise<ErrorResponse> => {
	const url = config.endpoints.error;
	const bodyData: ErrorRequestBody = {
		request: {
			correlationId: uuidv4(),
			timestamp: new Date().toISOString()
		},
		serviceName: 'frontend',
		error,
		info
	};

	removeAllCookies();

	return fetchData({
		url: url,
		method: FETCH_METHODS.POST,
		bodyData: JSON.stringify(bodyData),
		skipAuth: true
	});
}
Example #2
Source File: ErrorBoundary.tsx    From mitojs with MIT License 6 votes vote down vote up
componentDidCatch(error: Error, { componentStack }: ErrorInfo) {
    // error and componentStack are what we need
    const { onError, MitoInstance } = this.props
    const reactError = extractErrorStack(error, Severity.Normal) as ReportDataType
    reactError.type = ErrorTypes.REACT
    onError?.(error, componentStack)
    // mito handler -> collected react render error
    const breadcrumbStack = MitoInstance?.breadcrumb.push({
      type: BaseBreadcrumbTypes.REACT,
      data: reactError,
      category: BREADCRUMBCATEGORYS.EXCEPTION,
      level: Severity.Error
    })
    MitoInstance?.transport.send(reactError, breadcrumbStack)
    this.setState({
      hasError: true
    })
  }
Example #3
Source File: ErrorBoundary.tsx    From ke with MIT License 6 votes vote down vote up
componentDidCatch(error: Error, errorInfo: ErrorInfo): void {
    this.setState({
      error,
      errorInfo,
    })

    // eslint-disable-next-line react/destructuring-assignment
    this.context?.error?.(error)
  }
Example #4
Source File: ErrorBoundary.tsx    From backstage with Apache License 2.0 6 votes vote down vote up
ErrorBoundary: ComponentClass<
  ErrorBoundaryProps,
  State
> = class ErrorBoundary extends Component<ErrorBoundaryProps, State> {
  constructor(props: ErrorBoundaryProps) {
    super(props);
    this.state = {
      error: undefined,
      errorInfo: undefined,
    };
  }

  componentDidCatch(error: Error, errorInfo: ErrorInfo) {
    // eslint-disable-next-line no-console
    console.error(`ErrorBoundary, error: ${error}, info: ${errorInfo}`);
    this.setState({ error, errorInfo });
  }

  render() {
    const { slackChannel, children } = this.props;
    const { error } = this.state;

    if (!error) {
      return children;
    }

    return (
      <ErrorPanel title="Something Went Wrong" error={error}>
        <SlackLink slackChannel={slackChannel} />
      </ErrorPanel>
    );
  }
}
Example #5
Source File: _app.tsx    From next-right-now-admin with MIT License 6 votes vote down vote up
componentDidCatch(error: Error, errorInfo: ErrorInfo): void {
    Sentry.withScope((scope) => {
      Object.keys(errorInfo).forEach((key) => {
        scope.setExtra(key, errorInfo[key]);
      });

      Sentry.captureException(error);
    });

    // This is needed to render errors correctly in development / production
    super.componentDidCatch(error, errorInfo);
  }
Example #6
Source File: ErrorHandler.tsx    From Teyvat.moe with GNU General Public License v3.0 6 votes vote down vote up
/*
    The componentDidCatch Lifecycle Method is used to record
    the error which occurred. The componentDidCatch is not
    a factor in the rendering of the fallback error UI. In fact,
    this method will run after the re-rendering of the component
    to display the fallback UI
    If a componentDidCatch method is defined but the 
    getDerivedStateFromError method is not defined then an error
    will appear in the console stating that the getDerivedStateFromError
    should be defined.
    Here is the execution order:
    ** Task 1: JavaScript **
    - Error Boundary Component: Render
    - Error Thrown in Child Component
    - Error Boundary Component: getDerivedStateFromError
    - Error Boundary Component: Render to display Fallback UI
    - Error Boundary Component: componentDidCatch
    ** Task 2: Browser UI **
    - Paint
  */
  componentDidCatch(error: Error, errorInfo: ErrorInfo): void {
    // Add side effects here.
    this.setState({
      error,
      errorInfo,
    });
  }
Example #7
Source File: index.tsx    From metaflow-ui with Apache License 2.0 5 votes vote down vote up
public componentDidCatch(error: Error, errorInfo: ErrorInfo): void {
    console.error('Uncaught error:', error, errorInfo);
    this.setState({ hasError: true });
    const warning = `${error.name}: ${error.message}, ${errorInfo.componentStack?.split('\n')[1]}`;
    console.log(warning);
  }
Example #8
Source File: index.tsx    From drip-table with MIT License 5 votes vote down vote up
public componentDidCatch(error: unknown, errorInfo: ErrorInfo) {
    console.error(error, errorInfo);
  }
Example #9
Source File: App.tsx    From companion-kit with MIT License 5 votes vote down vote up
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
        console.error(error);
        this.processUnhandledError(error);
    }
Example #10
Source File: ErrorBoundary.tsx    From jmix-frontend with Apache License 2.0 5 votes vote down vote up
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
    console.error(error, errorInfo);
  }
Example #11
Source File: ErrorBoundary.tsx    From bee-dashboard with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
componentDidCatch(error: Error, errorInfo: ErrorInfo): void {
    // You can also log the error to an error reporting service
    console.error({ error, errorInfo }) // eslint-disable-line
  }
Example #12
Source File: IgnoreErrorBoundary.tsx    From yana with MIT License 5 votes vote down vote up
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
    // do nothing
  }
Example #13
Source File: ErrorBoundary.tsx    From firecms with MIT License 5 votes vote down vote up
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
        // logErrorToMyService(error, errorInfo);
    }
Example #14
Source File: ErrorBoundary.tsx    From kratos-selfservice-ui-react-native with Apache License 2.0 5 votes vote down vote up
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
    // You can also log the error to an error reporting service
    console.error(error, errorInfo)
  }
Example #15
Source File: App.tsx    From CrewLink with GNU General Public License v3.0 5 votes vote down vote up
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
		console.error('React Error: ', error, errorInfo);
	}
Example #16
Source File: ErrorBoundary.tsx    From Riakuto-StartingReact-ja3.1 with Apache License 2.0 5 votes vote down vote up
componentDidCatch = (error: Error, info: ErrorInfo): void => {
    console.error(error, info); // eslint-disable-line no-console
  };
Example #17
Source File: ErrorBoundary.tsx    From Riakuto-StartingReact-ja3.1 with Apache License 2.0 5 votes vote down vote up
componentDidCatch = (error: Error, info: ErrorInfo): void => {
    const { onError } = this.props;
    if (onError) onError();

    console.error(error, info); // eslint-disable-line no-console
  };
Example #18
Source File: ErrorBoundary.tsx    From phosphor-home with MIT License 5 votes vote down vote up
componentDidCatch(error: any, info: ErrorInfo) {
    void error;
    console.info(info);
  }
Example #19
Source File: Graphin.tsx    From memex with MIT License 5 votes vote down vote up
componentDidCatch(error: Error, info: ErrorInfo) {
    console.error('Catch component error: ', error, info);
  }