react-native-exception-handler icon indicating copy to clipboard operation
react-native-exception-handler copied to clipboard

TypeError's are not getting cached

Open Josema opened this issue 3 years ago • 0 comments

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)
})

image

Josema avatar Aug 05 '20 10:08 Josema