How to access the Unhandled Error in AppInsightsErrorBoundary onError prop with Application Insights in React

288 Views Asked by At

I have my application wrapped with the AppInsights context provider and error boundary like it's suggested by Microsoft here. One of the things I would like to do is have a custom component to display some of the error's info on the screen when handling an unhandled error. I'm having a difficult time finding any detailed documentation beyond the tiny snippet in the provided MS link.

When I try to add an error property to the onError function (spaghetti-at-wall attempt without more thorough documentation), it always passes in an empty object:

<AppInsightsErrorBoundary onError={(e) => <MyErrorComponent error={e} />} appInsights={reactPlugin}>
...
</AppInsightsErrorBoundary>

// error will alwyas equal {} inside of <MyErrorComponent />

Does anyone know how to gain access to the unhandled error Application Insights is capturing? So far, my only alternative is to make my own error boundary, but I'd prefer to use the MS provided one if at all possible.

0

There are 0 best solutions below