Exception Handler
npm install react-native-excNew React Native program error management library
Inspired by:
react-native-exception-handler
``sh`
npm install react-native-exc`
orsh`
yarn add react-native-exc
`bash`
$ cd ios
$ pod install
No further steps should be taken
`js
import { setJSExceptionHandler, setNativeExceptionHandler } from 'react-native-exc';
const errorHandler = (e: any, isFatal: any) => {
if (isFatal) {
Alert.alert(
'Unexpected error occurred',
Error: ${isFatal ? 'Fatal:' : ''} ${e.name} ${e.message}
We will need to restart the app.
,
[
{
text: 'Restart',
onPress: () => {
console.log('restart');
},
},
]
);
} else {
console.log(e); // So that we can see it in the ADB logs in case of Android if needed
}
};
setJSExceptionHandler(errorHandler);
//...
``
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
---
MRB