forked from madfish-solutions/templewallet-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandle-js-exception.js
32 lines (29 loc) · 945 Bytes
/
handle-js-exception.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import AsyncStorage from '@react-native-async-storage/async-storage';
import * as Sentry from '@sentry/react-native';
import { Alert } from 'react-native';
import { setJSExceptionHandler } from 'react-native-exception-handler';
import RNRestart from 'react-native-restart';
const allowInDevMode = false;
setJSExceptionHandler((error, isFatal) => {
Sentry.captureException(error.originalError ?? error);
isFatal &&
Alert.alert(
'Ooops, something went wrong',
'We have reported this to our team! \nRestart the app and try again. \nIf this continues - please Reset the wallet.',
[
{
text: 'Restart',
style: 'cancel',
onPress: () => RNRestart.Restart()
},
{
text: 'Reset',
style: 'destructive',
onPress: () => {
AsyncStorage.clear();
RNRestart.Restart();
}
}
]
);
}, allowInDevMode);