react-native-exception-handler
react-native-exception-handler copied to clipboard
TypeError's are not getting cached
My code:
// App.js
import {
setJSExceptionHandler,
setNativeExceptionHandler
} from 'react-native-exception-handler'
const errorHandler = (e, isFatal) => {
if (isFatal) {
Alert.alert(
'Unexpected error occurred',
`
Error: ${isFatal ? 'Fatal:' : ''} ${e.name} ${e.message}
We have reported this to our team ! Please close the app and start again!
`,
[
{
text: 'Close'
}
]
)
} else {
console.log(e) // So that we can see it in the ADB logs in case of Android if needed
}
}
setJSExceptionHandler(errorHandler, true)
setNativeExceptionHandler(errorString => {
errorHandler({ message: errorString }, true)
})