Is it posible propagate beforeCapture within withErrorBoundary from child to parent ? #9089
|
Hi! I'm using beforeCapture within withErrorBoundary in two elements, parent and child. But only the child beforeCapture is working. Is there a way to not catch the capture in the child, but allow to pass it to the parent so it also run its beforeCapture method? Imagine something like: export default Sentry.withErrorBoundary(RootElementWrapper, {
beforeCapture: (scope, error) => {
console.log("do something else", error);
scope.setTag("error",error.mesage)
},
});and export default Sentry.withErrorBoundary(PageElementWrapper, {
beforeCapture: (scope, error) => {
console.log("do something", error);
scope.setTag("location","page")
},
});The way it is: the console will only print: "do something" |
Replies: 2 comments
|
Could this be a solution, if added to every child? This way the children would set the tag and whenever there is an error, the parent would react with withErrorBoundary. useEffect(() => {
Sentry.configureScope((scope) => {
scope.setTag("location", "checkout");
});
}, []); |
|
Swallowing the error is in the nature of an error boundary. If you want a parent error boundary to become aware of an error that was already caught in a child error boundary you would need to rethrow the error in the child error boundary. Please note that the SDK is deduplicating errors so the errors won't be sent to Sentry twice. |
Swallowing the error is in the nature of an error boundary. If you want a parent error boundary to become aware of an error that was already caught in a child error boundary you would need to rethrow the error in the child error boundary. Please note that the SDK is deduplicating errors so the errors won't be sent to Sentry twice.