carloscuesta/react-native-error-boundary

How to get stackTrace info in FallbackComponent?

Closed this issue · 2 comments

Description of the question

I know we can do…

<ErrorBoundary
   FallbackComponent={MyErrorPage}
   onError={(error: Error, stackTrace: string) =>{ console.log(stackTrace) }}
></ErrorBoundary>

But does it possible to get stackTrace info in MyErrorPage (FallbackComponent) by using props or something?

I don't want to do something about this outside MyErrorPage (FallbackComponent) sorry.

Thanks.

Validations

Hey! @l2aelba

Thanks for opening an issue, it's not possible to access the stackTrace outside of the scope of the onError function.

onError?: (error: Error, stackTrace: string) => void

The FallbackComponent only receives two props, error and resetError as you can see here:

<FallbackComponent
error={this.state.error}
resetError={this.resetError}
/>

I don't want to do something about this outside MyErrorPage (FallbackComponent) sorry.

Not sure if I follow this, can you elaborate a bit more what you're trying to achieve?

Usually the stackTrace shouldn't be exposed to your end users, it's something you should internally keep logged in your system. Therefore I don't think we should pass that to the FallbackComponent, given that you can capture it in the onError callback.

See:

Thanks for info.

I'm not sure also, I just thinking about stackTrace has a useful information to send, just that.

And I just want to use it in FallbackComponent easier.