mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-30 11:24:13 -05: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
|