mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
b795579ca0
[web] send OError info and OError tags/cause tracebacks to sentry GitOrigin-RevId: 0544768ca16fcafb63ec6116a573e83302cdbdd3
37 lines
943 B
JavaScript
37 lines
943 B
JavaScript
import { captureException } from './error-reporter'
|
|
import { ErrorBoundary } from 'react-error-boundary'
|
|
|
|
function errorHandler(error, componentStack) {
|
|
captureException(error, {
|
|
extra: {
|
|
componentStack,
|
|
},
|
|
tags: {
|
|
handler: 'react-error-boundary',
|
|
},
|
|
})
|
|
}
|
|
|
|
function DefaultFallbackComponent() {
|
|
return <></>
|
|
}
|
|
|
|
function withErrorBoundary(WrappedComponent, FallbackComponent) {
|
|
function ErrorBoundaryWrapper(props) {
|
|
return (
|
|
<ErrorBoundary
|
|
FallbackComponent={FallbackComponent || DefaultFallbackComponent}
|
|
onError={errorHandler}
|
|
>
|
|
<WrappedComponent {...props} />
|
|
</ErrorBoundary>
|
|
)
|
|
}
|
|
ErrorBoundaryWrapper.propTypes = WrappedComponent.propTypes
|
|
ErrorBoundaryWrapper.displayName = `WithErrorBoundaryWrapper${
|
|
WrappedComponent.displayName || WrappedComponent.name || 'Component'
|
|
}`
|
|
return ErrorBoundaryWrapper
|
|
}
|
|
|
|
export default withErrorBoundary
|