a7ul / react-native-exception-handler

A react native module that lets you to register a global error handler that can capture fatal/non fatal uncaught exceptions.
MIT License
1.58k stars 133 forks source link

setJSExceptionHandler is not caching the fatal error for android #104

Open piyushdesuvit opened 5 years ago

piyushdesuvit commented 5 years ago

image

const errorHandler = (e, isFatal) => {
    if (isFatal) {
        Alert.alert(
            'Unexpected error occurred',
            `Error: ${(isFatal) ? 'Fatal:' : ''} ${e.name} ${e.message}   Please close the app and start again.`, [{
                text: 'OK',
            }]
        );
    } else {

    }
};
setJSExceptionHandler((error, isFatal) => {
    console.log('setJSExceptionHandler-->', error, isFatal);
    errorHandler(error, isFatal);
}, true);

for error showing the componentWillUnmount method fatal error it is showing undefined

react-native version "^0.59.5", "react": "^16.8.6", "react-native-exception-handler": "^2.10.7",

cinder92 commented 5 years ago

same issue here Android 8

a1lu commented 5 years ago

same here android 7

a7ul commented 5 years ago

Does it not catch any errors ? I mean does it work without the isFatal check ?

const errorHandler = (e, isFatal) => {
    Alert.alert(
            'Unexpected error occurred'
        );
};

Also it would be really helpful if anyone can give a link to a repo where this issue occurs ?

a1lu commented 5 years ago

Nope is not working. My code: setJSExceptionHandler(errorHandler, true);

in constructor of main class. I still get the red ReferenceError screen for a undefined test() call

mstankov commented 5 years ago

Is anyone working on this? Can confirm the handler is not functioning properly.

ManigandanRaamanathan commented 5 years ago

@master-atul @piyushdesuvit I'm facing the same issue n both android and ios. The exception alert only displays in the beginning if declare the setNativeExceptionHandler method in iOS

a7ul commented 5 years ago

Can someone create a simple react native app repo with reproducible error ? So that we can take a look at it. @ManigandanRaamanathan @mstankov

ManigandanRaamanathan commented 5 years ago

@master-atul I'll get you the snack example code tomorrow

samisamsam commented 5 years ago

Is anybody find a solution about this please ?

vinchentsoKN commented 5 years ago

I have got the same issue here, both (error, isFatal) are undefined. Anyone working on this ?

donmezemre commented 3 years ago

i am still getting the same result. did anybody solve this problem? RN version 0.60.2 and i used the pod install to link the library.

This is what the library returns

Screen Shot 2020-11-11 at 14 12 44

The code that i used Screen Shot 2020-11-11 at 14 13 30

alessandroraffa commented 3 years ago

Same here:

const jsErrorHandler = (e, isFatal) => {
  console.warn(JSON.stringify({ e, isFatal })));
};
setJSExceptionHandler(jsErrorHandler, true);
{"e":"the componentWillUnmount method","isFatal":false}
Jarzka commented 3 years ago

Same here. I think I'm just going to use this:

ErrorUtils.setGlobalHandler((error, isFatal) => {
  console.log('fug!', error);
});
dongdyang commented 2 years ago

+1 andriod still crashes directly. but ios works fine without a crash (just not responsive).