We want to show some custom alert let user report or restart app before crash, whenever there is a uncaught exceptions in js
So we set global handler like setJSExceptionHandler before Sentry install to replace defaultHandler on raven-plugin.js.
setJSExceptionHandler = (customHandler = this.noop, allowedInDevMode = false) => {
const allowed = allowedInDevMode ? true : !__DEV__;
if (allowed) {
global.ErrorUtils.setGlobalHandler(customHandler);
} else {
console.log('Skipping setJSExceptionHandler: Reason: In DEV mode and allowedInDevMode = false');
}
};
const customHandler = (
e: { name: string, message: string },
isFatal: boolean
) => {
if (isFatal) {
Alert.alert('Unexpected error occurred', [
{
text: 'Report to our team',
onPress: () => {
reportCrash(e);
},
},
{
text: 'Restart App',
onPress: restartApp,
},
]);
} else {
console.log(e); // So that we can see it in the ADB logs in case of Android if needed
}
};
When we click button to trigger Sentry.crash() alert will show at first time, but second time seem to ignore exception after restart app on android.
Do we use the wrong way to show custom exception handler or have any suggestion for that?
Steps to reproduce:
Step 1: click button to trigger js exception
Step 2: restart app
Step 3: click button to trigger js exception again
I am closing all old issues, please if this is still a problem feel free to revive it.
Also, consider moving to our new SDK @sentry/react-native if it still happens there please open a new issue.
OS:
Platform:
Output of
node -v && npm -v && npm ls --prod --depth=0
Config:
I have following issue:
We want to show some custom alert let user report or restart app before crash, whenever there is a uncaught exceptions in js
So we set global handler like
setJSExceptionHandler
before Sentry install to replacedefaultHandler
on raven-plugin.js.When we click button to trigger
Sentry.crash()
alert will show at first time, but second time seem to ignore exception after restart app on android.Do we use the wrong way to show custom exception handler or have any suggestion for that?
Steps to reproduce:
Actual result:
Expected result: