Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Enhance AppInsightsErrorBoundary to Pass Error Details to onError Component#135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
floccini wants to merge1 commit intomicrosoft:main
base:main
Choose a base branch
Loading
fromfloccini:main

Conversation

floccini
Copy link

This PR introduces an enhancement to theAppInsightsErrorBoundary component by providing access to theerror anderrorInfo objects in theonError component, allowing developers to handle errors in a more customized way.

  • UpdatedsetState to include theerror anderrorInfo in the state when an error is caught.
  • Passed those two values as props to theonError component, allowing developers to easily extract that information.

Usage example:

typeErrorBoundary={error:Error|null;errorInfo:React.ErrorInfo|null;};consthandleError=({ error, errorInfo}:ErrorBoundary)=>{if(error?.message==='Session expired'){// Assuming a session expiration error was thrown somewhere in our applicationreturn(<h1>                    Session expired, redirecting to the authentication page...</h1>);}return(<h1>                An unknown error occurred while performing the operation.</h1>);};<AppInsightsErrorBoundaryappInsights={reactPlugin}onError={handleError}>     ...</AppInsightsErrorBoundary>;

This enhancement allows developers to customize the component displayed in response to an error by providing access to the error details. This is something that I needed at work and I also found someone who also needed it inthis Stack Overflow question.

@floccini
Copy link
Author

@microsoft-github-policy-service agree

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@floccini

[8]ページ先頭

©2009-2025 Movatter.jp