GithubHelp home page GithubHelp logo

a7ul / react-native-exception-handler Goto Github PK

View Code? Open in Web Editor NEW
1.6K 20.0 125.0 1016 KB

A react native module that lets you to register a global error handler that can capture fatal/non fatal uncaught exceptions.

License: MIT License

JavaScript 9.77% Java 38.67% Objective-C 45.24% Ruby 6.32%
exception-handler react react-native bug error openlibrary

react-native-exception-handler's Introduction

react-native-exception-handler npm

https://nodei.co/npm/react-native-exception-handler.png?downloads=true&downloadRank=true&stars=true

A react native module that lets you to register a global error handler that can capture fatal/non fatal uncaught exceptions. The module helps prevent abrupt crashing of RN Apps without a graceful message to the user.

In the current scenario:

  • In DEV mode , you get a RED Screen error pointing your errors.
  • In Bundled mode , the app just quits without any prompt ! 🙄

To tackle this we register a global error handler that could be used to for example:

  1. Send bug reports to dev team when the app crashes
  2. Show a creative dialog saying the user should restart the application

UPDATE - V2:

V2 of this module now supports catching Unhandled Native Exceptions also along with the JS Exceptions ✌🏻🍻 There are NO breaking changes. So its safe to upgrade from v1 to v2. So there is no reason not to 😉.

V2.9

  • Adds support for executing previously set error handlers (now this module can work with other analytics modules)
  • Adds an improved approach for overwriting native error handlers.
  • Thanks @ Damien Solimando

Example repo can be found here: _https://github.com/master-atul/react-native-exception-handler-example _

Screens

Without any error handling

In DEV MODE



In BUNDLED MODE



With react-native-exception-handler in BUNDLED MODE



Installation:

yarn add react-native-exception-handler

or

npm i react-native-exception-handler --save

Mostly automatic installation

react-native link react-native-exception-handler

For [email protected] or above

As [email protected] or above supports autolinking, so there is no need to run linking process. Read more about autolinking here.

Manual installation

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-exception-handler and add ReactNativeExceptionHandler.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libReactNativeExceptionHandler.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<
Using Cocoapods
  1. add pod 'ReactNativeExceptionHandler', :podspec => '../node_modules/react-native-exception-handler/ReactNativeExceptionHandler.podspec' to your Podfile
  2. run pod install

Android

  1. Open up android/app/src/main/java/[...]/MainApplication.java
  • Add import com.masteratul.exceptionhandler.ReactNativeExceptionHandlerPackage; to the imports at the top of the file
  • Add new ReactNativeExceptionHandlerPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-exception-handler'
    project(':react-native-exception-handler').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-exception-handler/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-exception-handler')
    

PLEASE READ BEFORE GOING TO USAGE SECTION

Lets introduce you to the type of errors in a RN app.

  • Errors produced by your Javascript code (includes all your react code). We will refer to these errors as JS_Exceptions going forward.

  • Errors produced by Native Modules. We will refer to these as Native_Exceptions going forward.

Unhandled exceptions leave the app in a critical state.

In case of JS_Exceptions you can catch these unhandled exceptions and perform tasks like show alerts or popups, do cleanup or even hit an API to inform the dev teams before closing the app.

In case of Native_Exceptions it becomes much worse. While you can catch these unhandled exceptions and perform tasks like cleanup or logout or even hit an API to inform the dev teams before closing the app, you CANNOT show a JS alert box or do any UI stuff via JS code. This has to be done via the native methods provided by this module in the respective NATIVE codebase for iOS and android. The module does provide default handlers though :P. So you will get default popups incase of errors. Obviously you can customise them. See CUSTOMIZATION section.

Usage

To catch JS_Exceptions

import {setJSExceptionHandler, getJSExceptionHandler} from 'react-native-exception-handler';

.
.
// For most use cases:
// registering the error handler (maybe u can do this in the index.android.js or index.ios.js)
setJSExceptionHandler((error, isFatal) => {
  // This is your custom global error handler
  // You do stuff like show an error dialog
  // or hit google analytics to track crashes
  // or hit a custom api to inform the dev team.
});
//=================================================
// ADVANCED use case:
const exceptionhandler = (error, isFatal) => {
  // your error handler function
};
setJSExceptionHandler(exceptionhandler, allowInDevMode);
// - exceptionhandler is the exception handler function
// - allowInDevMode is an optional parameter is a boolean.
//   If set to true the handler to be called in place of RED screen
//   in development mode also.

// getJSExceptionHandler gives the currently set JS exception handler
const currentHandler = getJSExceptionHandler();

To catch Native_Exceptions

import { setNativeExceptionHandler } from "react-native-exception-handler";

//For most use cases:
setNativeExceptionHandler((exceptionString) => {
  // This is your custom global error handler
  // You do stuff likehit google analytics to track crashes.
  // or hit a custom api to inform the dev team.
  //NOTE: alert or showing any UI change via JS
  //WILL NOT WORK in case of NATIVE ERRORS.
});
//====================================================
// ADVANCED use case:
const exceptionhandler = (exceptionString) => {
  // your exception handler code here
};
setNativeExceptionHandler(
  exceptionhandler,
  forceAppQuit,
  executeDefaultHandler
);
// - exceptionhandler is the exception handler function
// - forceAppQuit is an optional ANDROID specific parameter that defines
//    if the app should be force quit on error.  default value is true.
//    To see usecase check the common issues section.
// - executeDefaultHandler is an optional boolean (both IOS, ANDROID)
//    It executes previous exception handlers if set by some other module.
//    It will come handy when you use any other crash analytics module along with this one
//    Default value is set to false. Set to true if you are using other analytics modules.

It is recommended you set both the handlers. NOTE: setNativeExceptionHandler only works in bundled mode - it will show the red screen when applied to dev mode.

See the examples to know more

CUSTOMIZATION

Customizing setJSExceptionHandler.

In case of setJSExceptionHandler you can do everything that is possible. Hence there is not much to customize here.

const errorHandler = (error, isFatal) => {
  // This is your custom global error handler
  // You do stuff like show an error dialog
  // or hit google analytics to track crashes
  // or hit a custom api to inform the dev team.
})
//Second argument is a boolean with a default value of false if unspecified.
//If set to true the handler to be called in place of RED screen
//in development mode also.
setJSExceptionHandler(errorHandler, true);

Customizing setNativeExceptionHandler

By default whenever a Native_Exceptions occurs if you have used setNativeExceptionHandler, along with the callback specified you would see a popup (this is the default native handler set by this module).

In Android and iOS you will see something like

Modifying Android Native Exception handler (RECOMMENDED APPROACH)

(NATIVE CODE HAS TO BE WRITTEN) recommended that you do this in android studio

  • In the android/app/src/main/java/[...]/MainApplication.java
import com.masteratul.exceptionhandler.ReactNativeExceptionHandlerModule;
import com.masteratul.exceptionhandler.NativeExceptionHandlerIfc
...
...
...
public class MainApplication extends Application implements ReactApplication {
...
...
  @Override
  public void onCreate() {
    ....
    ....
    ....
    ReactNativeExceptionHandlerModule.setNativeExceptionHandler(new NativeExceptionHandlerIfc() {
      @Override
      public void handleNativeException(Thread thread, Throwable throwable, Thread.UncaughtExceptionHandler originalHandler) {
        // Put your error handling code here
      }
    });//This will override the default behaviour of displaying the recover activity.
  }

Modifying Android Native Exception handler UI (CUSTOM ACTIVITY APPROACH (OLD APPROACH).. LEAVING FOR BACKWARD COMPATIBILITY)

(NATIVE CODE HAS TO BE WRITTEN) recommended that you do this in android studio

  • Create an Empty Activity in the android/app/src/main/java/[...]/. For example lets say CustomErrorDialog.java
  • Customize your activity to look and behave however you need it to be.
  • In the android/app/src/main/java/[...]/MainApplication.java
import com.masteratul.exceptionhandler.ReactNativeExceptionHandlerModule;
import <yourpackage>.YourCustomActivity; //This is your CustomErrorDialog.java
...
...
...
public class MainApplication extends Application implements ReactApplication {
...
...
  @Override
  public void onCreate() {
    ....
    ....
    ....
    ReactNativeExceptionHandlerModule.replaceErrorScreenActivityClass(YourCustomActivity.class); //This will replace the native error handler popup with your own custom activity.
  }

Modifying iOS Native Exception handler UI (NATIVE CODE HAS TO BE WRITTEN) recommended that you do this in XCode

Unlike Android, in the case of iOS, there is no way to restart the app if it has crashed. Also, during a Native_Exceptions the UI becomes quite unstable since the exception occured on the main UI thread. Hence, none of the click or press handlers would work either.

Keeping in mind of these, at the most we can just show the user a dialog and inform the user to reopen the app.

If you noticed the default native exception popup does exactly that. To customize the UI for the popup.

  • In XCode, open the file AppDelegate.m
#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>

//Add the header file
#import "ReactNativeExceptionHandler.h"
...
...
@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
...

[ReactNativeExceptionHandler replaceNativeExceptionHandlerBlock:^(NSException *exception, NSString *readeableException){

    // THE CODE YOU WRITE HERE WILL REPLACE THE EXISTING NATIVE POPUP THAT COMES WITH THIS MODULE.
    //We create an alert box
    UIAlertController* alert = [UIAlertController
                                alertControllerWithTitle:@"Critical error occurred"
                                message: [NSString stringWithFormat:@"%@\n%@",
                                          @"Apologies..The app will close now \nPlease restart the app\n",
                                          readeableException]
                                preferredStyle:UIAlertControllerStyleAlert];

    // We show the alert box using the rootViewController
    [rootViewController presentViewController:alert animated:YES completion:nil];

    // THIS IS THE IMPORTANT PART
    // By default when an exception is raised we will show an alert box as per our code.
    // But since our buttons wont work because our click handlers wont work.
    // to close the app or to remove the UI lockup on exception.
    // we need to call this method
    // [ReactNativeExceptionHandler releaseExceptionHold]; // to release the lock and let the app crash.

    // Hence we set a timer of 4 secs and then call the method releaseExceptionHold to quit the app after
    // 4 secs of showing the popup
    [NSTimer scheduledTimerWithTimeInterval:4.0
                                     target:[ReactNativeExceptionHandler class]
                                   selector:@selector(releaseExceptionHold)
                                   userInfo:nil
                                    repeats:NO];

    // or  you can call
    // [ReactNativeExceptionHandler releaseExceptionHold]; when you are done to release the UI lock.
  }];

...
...
...

 return YES;
}

@end

What is this [ReactNativeExceptionHandler releaseExceptionHold];?

In case of iOS we lock the UI thread after we show our popup to prevent the app from closing. Hence once we are done showing the popup we need to close our app after some time. But since our buttons wont work as our click handlers wont work (explained before). To close the app or to remove the UI lockup on exception, we need to call this method [ReactNativeExceptionHandler releaseExceptionHold];

Hence we set a timer of 4 secs and then call the method releaseExceptionHold to quit the app after 4 secs of showing the popup

[NSTimer scheduledTimerWithTimeInterval:4.0
                                 target:[ReactNativeExceptionHandler class]
                               selector:@selector(releaseExceptionHold)
                               userInfo:nil
                                repeats:NO];

Examples

Restart on error example

This example shows how to use this module show a graceful bug dialog to the user on crash and restart the app when the user presses ok !

import {Alert} from 'react-native';
import RNRestart from 'react-native-restart';
import {setJSExceptionHandler} from 'react-native-exception-handler';

const errorHandler = (e, isFatal) => {
  if (isFatal) {
    Alert.alert(
        'Unexpected error occurred',
        `
        Error: ${(isFatal) ? 'Fatal:' : ''} ${e.name} ${e.message}

        We will need to restart the app.
        `,
      [{
        text: 'Restart',
        onPress: () => {
          RNRestart.Restart();
        }
      }]
    );
  } else {
    console.log(e); // So that we can see it in the ADB logs in case of Android if needed
  }
};

setJSExceptionHandler(errorHandler);

setNativeExceptionHandler((errorString) => {
    //You can do something like call an api to report to dev team here
    ...
    ...
   // When you call setNativeExceptionHandler, react-native-exception-handler sets a
   // Native Exception Handler popup which supports restart on error in case of android.
   // In case of iOS, it is not possible to restart the app programmatically, so we just show an error popup and close the app.
   // To customize the popup screen take a look at CUSTOMIZATION section.
});

Bug Capture to dev team example

This example shows how to use this module to send global errors to the dev team and show a graceful bug dialog to the user on crash !

import { Alert } from "react-native";
import { BackAndroid } from "react-native";
import { setJSExceptionHandler } from "react-native-exception-handler";

const reporter = (error) => {
  // Logic for reporting to devs
  // Example : Log issues to github issues using github apis.
  console.log(error); // sample
};

const errorHandler = (e, isFatal) => {
  if (isFatal) {
    reporter(e);
    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",
          onPress: () => {
            BackAndroid.exitApp();
          },
        },
      ]
    );
  } else {
    console.log(e); // So that we can see it in the ADB logs in case of Android if needed
  }
};

setJSExceptionHandler(errorHandler);

setNativeExceptionHandler((errorString) => {
  //You can do something like call an api to report to dev team here
  //example
  // fetch('http://<YOUR API TO REPORT TO DEV TEAM>?error='+errorString);
  //
});

More Examples can be found in the examples folder

  • Preserving old handler (thanks to zeh)

Known issues and fixes:

react-native-navigation (Wix)

This is specifically occuring when you use wix library for navigation along with react-native-exception-handler. Whenever an error occurs, it will recreate the application above the crash screen.

Fix:

You need to set second parametera as false while calling setNativeExceptionHandler. The second parameter is an android specific field which stands for forceQuitOnError. When set to false it doesnt quit the app forcefully on error. In short :

Credit goes to Gustavo Fão Valvassori

setNativeExceptionHandler(nativeErrorCallback, false);

Previously defined exception handlers are not executed anymore

A lot of frameworks (especially analytics sdk's) implement global exception handlers. In order to keep these frameworks working while using react-native-exception-hanlder, you can pass a boolean value as third argument to setNativeExceptionHandler(..., ..., true) what will trigger the execution of the last global handler registered.

CONTRIBUTORS

TESTING NATIVE EXCEPTIONS/ERRORS

To make sure this module works. You can generate a native exception using the module rn-test-exception-handler. https://github.com/master-atul/rn-test-exception-handler

rn-test-exception-handler module does only one thing. It raises a Native_Exceptions. This will help you to verify your customizations or functionality of this module.

Peace ! ✌🏻🍻

react-native-exception-handler's People

Contributors

a7ul avatar alexovits avatar dsolimando avatar faogustavo avatar fchasen avatar gantman avatar himanshusingh2407 avatar jerolimov avatar joshuapinter avatar kasinskas avatar lexor90 avatar mark-friedman avatar pesterhazy avatar peteroid avatar robinxb avatar robrechtme avatar sameeramadushan avatar skrafft avatar slavikdenis avatar tommahle avatar tspop avatar vyazovoy avatar zeh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-exception-handler's Issues

not capturing my exception which is shown in debugger console : warning - exception while invoking a callback: ReferenceError: ahb is not defined

I have created a normal class in react native and calling its function.
Inside that function I got an error which is displayed in the debugger console :

warning - exception while invoking a callback: ReferenceError: ahb is not defined

The thing is it is not being captured by this module.

If bug came on a page where render() function is present , it is captured by this module.

Regards,
Varun Prashar

Not able to get Custom error message in bunndle mode or dev mode on genyMotion android simulator

import React from 'react';
import {Text, View, StyleSheet, Button,Alert, TouchableOpacity,NativeModules} from 'react-native';

import {setJSExceptionHandler,getJSExceptionHandler} from 'react-native-exception-handler';

const {ReactNativeExceptionHandler} = NativeModules;

const errorHandler = (e, isFatal) =>{

console.log("xxxxxx");
console.warn("YYYYYYYY");

Alert.alert(
    'Sorry ',
    ` Error :${(isFatal)? 'Fatal':''} ${e.name} ${e.message}
    we have reported to the team!
    `
        [
    {text: 'OK'}
        ],
    { cancelable: false }
)

}
setJSExceptionHandler(errorHandler,true);

ReactNativeExceptionHandler.setHandlerforNativeException( true ,(value) =>{
console.warn("Happy bahg jaye gii")
});

class JSErrorHandler extends React.Component{
constructor(props){
super(props);
}
render(){
return(

Here will be fun
<TouchableOpacity onPress={()=>{
this.test()
}}>
hello


)
}
}

const styles = StyleSheet.create({
container : {
flex:1,
justifyContent:"center"
}
})
export default JSErrorHandler;

Skipping setJSExceptionHandler: Reason: In DEV mode and allowedInDevMode = false

I placed the error-handler inside index-file like this:

// registering the error handler (maybe u can do this in the index.android.js or index.ios.js)
setJSExceptionHandler((error, isFatal) => {
// This is your custom global error handler
// You do stuff like show an error dialog
// or hit google analytics to track crashes
// or hit a custom api to inform the dev team.
// Error saving data
try {
AsyncStorage.setItem('Error', error.toString());
} catch (error) {
// Error saving data
}

});

// getJSExceptionHandler gives the currently set JS exception handler
const currentHandler = getJSExceptionHandler();

How can i set In DEV mode to true.

Error with redux not handled

I am using redux to handle state. Whenever state changes function is rendered and render function contains an error (missing component). This error is not captured by this function.

I have tried with both dev mode as well as release mode. Other than redux my configuration works great.

It doesn't work at all

I have created the AwesomeProject following the guideline https://facebook.github.io/react-native/docs/getting-started.html and the handlers don't work.

My code

import { AppRegistry, Alert } from 'react-native';
import App from './App';
import { setJSExceptionHandler, setNativeExceptionHandler } from 'react-native-exception-handler';

AppRegistry.registerComponent('AwesomeProject', () => App);

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

setNativeExceptionHandler((errorString) => {
    console.log('setNativeExceptionHandler');
});

Here my environment:
"react": "16.2.0",
"react-native": "0.53.3",

Can't get it to work in bundled mode (RN in existing Android app)

We have an Android app that we are integrating RN to. I just added the react-native-exception-handler, and it seems to work when I'm running the app in debug mode, getting the logging, the alert box and the red RN error. But when I bundle the files, it doesn't seem to work at all.

package.json

    "react": "16.0.0",
    "react-native": "0.50.3",
    "react-native-exception-handler": "^2.4.0",

xyz.js (Logger is a native module that just logs to the terminal)

import {setJSExceptionHandler} from 'react-native-exception-handler';

const errorHandler = (error, isFatal) => {
    console.log('Got an uncaught exception')
    Logger.log('Got an uncaught exception')
    Logger.log('Fatal: ' + isFatal)
    Logger.log('Name: ' + error.name)
    Logger.log('Message: ' + error.message)

    Alert.alert('Error', 'Uncaught error', [{ text: 'OK'}])
}

setJSExceptionHandler(errorHandler, true)

From Android project

private ReactInstanceManager createReactInstanceManager() {
        return ReactInstanceManager.builder()
                .setApplication(getApplication())
                .setBundleAssetName("index.android.bundle")
                .setJSMainModulePath("index")
                .addPackage(new MainReactPackage())
                .addPackage(new ReactNativeExceptionHandlerPackage())
                .addPackage(... other packages ...)
                .setUseDeveloperSupport(BuildConfig.DEBUG)
                .setInitialLifecycleState(LifecycleState.RESUMED)
                .build();
    }

More useful errors?

Logging the errors from this in a production only gives this:

{ "line" : 364, "column" : 3179, "sourceURL" : "index.android.bundle" }

Which isn't a very clear way to show what the actual javascript error was.

Is there another way?

Not calling the JS Error Handler

Added the error handler before the app class but it is not being called.

const errorHandler = (e, isFatal) => {
  if (isFatal) {
    console.log("from Error Handler", e);
    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",
          onPress: () => {
            BackAndroid.exitApp();
          }
        }
      ]
    );
  } else {
    console.log(e); // So that we can see it in the ADB logs in case of Android if needed
  }
};

setJSExceptionHandler(errorHandler, true);
 
export default class App extends Component {
.....
}

in component render method, added the following error function

render(){
   this.test() // throws error
   return (
   .......
   )
}

React native version is 0.52 and testing it on android simulator.

Where do I put setNativeExceptionHandler?

Hi. I'm quite confused as to where to put setNativeExceptionHandler. I tried to put it nearby setJSExceptionHandler in index.js but it doesn't seem to work that way. I threw native error with your test library and I think it shouldn't even get there if it crushes before running javascript.

Doesn't work inside promises?

It does not seem to catch any errors inside promises for me.

I'm navigating to a different view using react-navigation inside a promise, and no errors are caught after this (or inside the promise itself).

fetchUser().then(() => { this.causeAnError() })

Cannot read property 'setHandlerforNativeException' of undefined

Hi,

Just followed the doc and got this error on app start.

image

Below is my setup


import React from 'react'
import { Provider } from 'react-redux'
import { Sentry } from 'react-native-sentry';
import { setJSExceptionHandler, setNativeExceptionHandler } from 'react-native-exception-handler';

// Set global error handler
setJSExceptionHandler((error, isFatal) => {
  if (isFatal) {
    Alert.alert(
      'Unexpected error occurred',
      `
      Error: ${(isFatal) ? 'Fatal:' : ''} ${error.name} ${error.message}
      Please close the app and start again!
      `,
      [{
        text: 'Close',
      }],
    );
  }
}, true);

setNativeExceptionHandler((exceptionString) => {
  // log error to Sentry
  Sentry.captureException(new Error(exceptionString), {
    logger: 'NativeExceptionHandler',
  });
}, false);

version:

"react-native": "0.55.2",
"react-native-exception-handler": "^2.7.5",

Error on Android..

Hi, I'm trying to add errorHandler in my component, but it will give me the same red error.

error

code

is there something that i missed?

#Thanks

i get no popup/alert for native exceptions

The console.log is being called but as documented should i get a default popup message too?

setNativeExceptionHandler((errorString) => {
    console.log('setNativeExceptionHandler', errorString);
});

Handling native exceptions didn't work in Android release APK

// catch.js
import {
  Platform,

} from 'react-native';
import {
  setJSExceptionHandler,
  setNativeExceptionHandler
} from "react-native-exception-handler";

const server_url = '' // server url
const reporter = (error, type) => {
  const e_obj = {
    type,
    error,
    time: new Date().getTime(),
    system: Platform.OS,
  }

  fetch(server_url+'/__native_error', {
    headers: {'Content-Type': 'application/x-www-form-urlencoded'},
    method: 'POST',
    body: 'error=' + JSON.stringify(e_obj)
  }).then(res => res.text()).catch(e => {
    console.log(e, e_obj)
  })
};

const errorHandler = (e, isFatal) => {
  if (isFatal) {
    reporter(e, 'js');
  } else {
    console.log(e); // So that we can see it in the ADB logs in case of Android if needed
  }
};

setJSExceptionHandler(errorHandler);

setNativeExceptionHandler((errorString) => {
  reporter(errorString, 'native');
}, true);

And I have two buttons:

import React from 'react';
import {Button, View} from 'react-native';
import RnTestExceptionHandler from 'rn-test-exception-handler';
import './catch.js';

export default class App extends React.Component {
	render() {
       return (
         <View>
           <Button title="Set JS Exception" onPress={() => {
             a() 
           }}/>
           <Button title="Set Native Exception" onPress={() => {
             RnTestExceptionHandler.raiseTestNativeError() 
           }}/>
         </View>
       )
    }
} 

I build a release APK, install it in my phone.
When I click the first button, my server has received the error message. But click the second button, it just show a error interface, no message send to my server.

Handling exceptions in Android release APK

Hello,

I am able to catch JS as well as Native exceptions in Debug APK. But the exceptions are not caught in Release APK. Can you please suggest I am missing anything? Here is my code:

import { AppRegistry, Alert } from 'react-native';
import App from './App';
import {setJSExceptionHandler, setNativeExceptionHandler} from 'react-native-exception-handler';
import RNRestart from 'react-native-restart';

const reporter = (error) => {
    console.log(error); 
};

const errorHandler = (e, isFatal) => {
    if (isFatal) {
      reporter(e);
      Alert.alert(
          'Unexpected error occurred',
          'Error: ${(isFatal) ? 'Fatal:' : ''} ${e.name} ${e.message}Please close the app and start again!',
        [{
          text: 'Restart',
          onPress: () => {
            RNRestart.Restart();
          }
        }]
      );
    } else {
      console.log(e); 
    }
  };
setJSExceptionHandler(errorHandler, true);
setNativeExceptionHandler((errorString => {
  console.log('Native exception !!!');
}), true);

Doesn't seem to be working

No error seems to be caught, yellow boxes and red boxes still show up on __DEV__ === true and app simply closes on Release mode.

Added the following code to my app:

// index.ios.js

import { setJSExceptionHandler } from 'react-native-exception-handler';

setJSExceptionHandler(error => console.log('error', error), true);

__DEV__: true;
Platform: iOS;

// package.json
{
  ...
  "react": "16.0.0-alpha.12",
  "react-native-exception-handler": "^2.3.0",
  "react-native": "0.47.2",
  ...
}

Error: Redefinition of 'RCTMethodInfo' when including ReactNativeExceptionHandler.h

When I include ReactNativeExceptionHandler.h in AppDelegate.m in order to use replaceNativeExceptionHandlerBlock, I get:

screenshot 2018-03-18 14 29 11

If I go into ReactNativeExceptionHandler.h and change:

#if __has_include("RCTBridgeModule.h")
#import "RCTBridgeModule.h"
#else
#import <React/RCTBridgeModule.h>
#endif

To just:

#import <React/RCTBridgeModule.h>

The problem goes away.

What could this be a symptom of?

Handling of SIGPIPE (lock screen)

Thanks for this very useful library!

Including native code in an app, I sometimes see a "Signal 13 was raised" message in the "Unexpected error occurred" modal. This happens when the app is reopened after being inactive for a while, after opening the lock screen.

Running signal(SIGPIPE, SIG_IGN); doesn't fix this.

The problem is that react-native-exception-handler sets its own signal handler, overriding the user-provided one:

https://github.com/master-atul/react-native-exception-handler/blob/master/ios/ReactNativeExceptionHandler.m#L76

To fix this IMO the library should

  1. ignore SIGPIPE by default (which should be safe and a good default) or
  2. provide an option to ignore SIGPIPE or
  3. not touch SIGPIPE at all, leaving the choice to the user

I think (1) is best. What do you think?

Build conflict with Mixpanel

For IOS, I encountered build conflict problem after I do react-native link react-native-exception-handler ( it works fine without linking ).

This following are the error messages:

duplicate symbol _UncaughtExceptionHandlerAddressesKey in:
   /<project_path>/ios/build/Build/Products/Debug-iphonesimulator/Mixpanel/libMixpanel.a(MixpanelExceptionHandler.o)
   /<project_path>/ios/build/Build/Products/Debug-iphonesimulator/libReactNativeExceptionHandler.a(ReactNativeExceptionHandler.o)
duplicate symbol _UncaughtExceptionHandlerSignalKey in:
   /<project_path>/ios/build/Build/Products/Debug-iphonesimulator/Mixpanel/libMixpanel.a(MixpanelExceptionHandler.o)
   /<project_path>/ios/build/Build/Products/Debug-iphonesimulator/libReactNativeExceptionHandler.a(ReactNativeExceptionHandler.o)
duplicate symbol _UncaughtExceptionHandlerReportAddressCount in:
   /<project_path>/ios/build/Build/Products/Debug-iphonesimulator/Mixpanel/libMixpanel.a(MixpanelExceptionHandler.o)
   /<project_path>/ios/build/Build/Products/Debug-iphonesimulator/libReactNativeExceptionHandler.a(ReactNativeExceptionHandler.o)
duplicate symbol _UncaughtExceptionHandlerSkipAddressCount in:
   /<project_path>/ios/build/Build/Products/Debug-iphonesimulator/Mixpanel/libMixpanel.a(MixpanelExceptionHandler.o)
   /<project_path>/ios/build/Build/Products/Debug-iphonesimulator/libReactNativeExceptionHandler.a(ReactNativeExceptionHandler.o)
duplicate symbol _UncaughtExceptionCount in:
   /<project_path>/ios/build/Build/Products/Debug-iphonesimulator/Mixpanel/libMixpanel.a(MixpanelExceptionHandler.o)
   /<project_path>/ios/build/Build/Products/Debug-iphonesimulator/libReactNativeExceptionHandler.a(ReactNativeExceptionHandler.o)
duplicate symbol _UncaughtExceptionMaximum in:
   /<project_path>/ios/build/Build/Products/Debug-iphonesimulator/Mixpanel/libMixpanel.a(MixpanelExceptionHandler.o)
   /<project_path>/ios/build/Build/Products/Debug-iphonesimulator/libReactNativeExceptionHandler.a(ReactNativeExceptionHandler.o)
duplicate symbol _UncaughtExceptionHandlerSignalExceptionName in:
   /<project_path>/ios/build/Build/Products/Debug-iphonesimulator/Mixpanel/libMixpanel.a(MixpanelExceptionHandler.o)
   /<project_path>/ios/build/Build/Products/Debug-iphonesimulator/libReactNativeExceptionHandler.a(ReactNativeExceptionHandler.o)
ld: 7 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Not showing native exception UI on iOS

My app just crashes, with no exception UI being shown. I'm setting the native exception handling as follows in my code:

    setNativeExceptionHandler((exceptionString) => {
    });

I am using rn-test-exception-handler to cause the exception in this app.

I am seeing the following logged before the app crashes:

2018-06-19 16:48:57.378263-0700 ThunkableCompanion[19184:43689367] Exception 'THIS IS A TEST EXCEPTION' was thrown while invoking raiseTestNativeError on target RnTestExceptionHandler with params (
)
callstack: (
	0   CoreFoundation                      0x00000001142701e6 __exceptionPreprocess + 294
	1   libobjc.A.dylib                     0x00000001126ea031 objc_exception_throw + 48
	2   CoreFoundation                      0x00000001142e5975 +[NSException raise:format:] + 197
	3   ThunkableCompanion                  0x000000010b496daa -[RnTestExceptionHandler raiseTestNativeError] + 90
	4   CoreFoundation                      0x00000001141f3ccc __invoking___ + 140
	5   CoreFoundation                      0x00000001141f3b84 -[NSInvocation invoke] + 308
	6   CoreFoundation                      0x000000011420c8d6 -[NSInvocation invokeWithTarget:] + 54
	7   ThunkableCompanion                  0x000000010aba2a7c -[RCTModuleMethod invokeWithBridge:module:arguments:] + 2796
	8   ThunkableCompanion                  0x000000010ac3b112 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 786
	9   ThunkableCompanion                  0x000000010ac3ac3f _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 127
	10  ThunkableCompanion                  0x000000010ac3abb9 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 25
	11  libdispatch.dylib                   0x00000001155a1807 _dispatch_call_block_and_release + 12
	12  libdispatch.dylib                   0x00000001155a2848 _dispatch_client_callout + 8
	13  libdispatch.dylib                   0x00000001155ad92b _dispatch_main_queue_callback_4CF + 628
	14  CoreFoundation                      0x0000000114232c99 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
	15  CoreFoundation                      0x00000001141f6ea6 __CFRunLoopRun + 2342
	16  CoreFoundation                      0x00000001141f630b CFRunLoopRunSpecific + 635
	17  GraphicsServices                    0x0000000117163a73 GSEventRunModal + 62
	18  UIKit                               0x000000010f9fc0b7 UIApplicationMain + 159
	19  ThunkableCompanion                  0x000000010aaa5c2f main + 111
	20  libdyld.dylib                       0x000000011561f955 start + 1
)
reactConsoleErrorHandler @ index.bundle:12399
console.error @ index.bundle:45360
logToConsole @ index.bundle:18772
logIfNoNativeHook @ index.bundle:18755
__callFunction @ index.bundle:7562
(anonymous) @ index.bundle:7391
__guard @ index.bundle:7533
callFunctionReturnFlushedQueue @ index.bundle:7390
(anonymous) @ debuggerWorker.js:72

I attempted to debug this in Xcode and set breakpoints at the beginning of handleException() in ReactNativeExceptionHandler.m but the code never seemed to get to that breakpoint. Instead I just got continual exceptions within React Native's invokeInner() method (in RCTNativeModule.mm)

The error that appears there in Xcode is:

Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)

I am also seeing a yellow box in my app (which I'm running in React Native's Dev/Debug mode) with the following message. It's not clear whether that is relevent but I'm noting it hear for completeness.

RCTBridge required dispatch_sync to load RCTDevLoadingView.  This may lead to deadlocks.

example for React 16 `componentDidCatch `

Hi,
React 16 provide componentDidCatch method that catch errors during rendering, could you please provide a example how react-native-exception-handler integration with it?

Another question, in the PROD environment, after exception message reported to DEV TEAM, how can we location the code file name and line number that throws the exception?

setNativeExceptionHandler callback is not being invoked on Android

All I was trying to do was a console.log() in that callback.

    setNativeExceptionHandler((exceptionString) => {
      console.log(exceptionString);
    });

The exception that is being triggered is fairly deep in some native View rendering code (originally thrown, I believe, here, and then caught and rethrown here).

At first I set a breakpoint at that console.log() using the React Native debugger within Chrome and saw that the breakpoint was never getting reached.

Thinking that maybe there was some bad interaction between native code and the React Native debugger, I ran our app under the Android Studio debugger and set a breakpoint immediately before and after the invocation of the callback supplied to setNativeExceptionHandler (here). Doing so, I noticed the following message displayed in logcat during that invocation:

W/unknown:ReactNative: Invoking JS callback after bridge has been destroyed.

This could explain why we weren't seeing the result of the execution of that callback.

Interface stuck after crash on Android

According to the documentation, I should see an alert box on Android. Instead I get a black screen. It is worth noting that I'm using react-native-navigator from wix, so it might be related. Is there an option to disable the alert screen and just let the app crashes, as it normally would?

Find more useful errors (tip)

This is not a issue. this is a debug tip 🥇

Ref: @allthetime #56

{ "line" : 364, "column" : 3179, "sourceURL" : "index.android.bundle" }

Load bundle javascript in html, and open in chrome:

image

And you will find what code occure the error

setNativeExceptionHandler is not working properly

I am trying to handle native errors using setNativeExceptionHandler but when an error is thrown from the native modules then the default red screen is being shown.

setNativeExceptionHandler((errorString) => { console.log(errorString); });

I think ReactNativeExceptionHandler.setHandlerforNativeException(forceApplicationToQuit, customErrorHandler); is not working as aspected.

Raising the issue on react-native

Background View

Hi team,

Is that possible to showcase the exception popup top of the application home page, Like if the app got crashed any other pages, I wish you to showcase the popup top of my app home page instead of plain background. Is that any feasibility to do ? Pls suggest. Thanks in advance.
screen shot 2018-08-10 at 2 40 57 am

UI change when exception is caught

Hi, I am new to react-native and I have a quick question. I 'd like to redirect the user to another page when an exception is caught, but now it seems the ui is unable to recover and the app freezes. I am wondering whether its possible to achieve that. Thanks for any advice.

Don't overwrite pre-existing native handlers on iOS

This is a copy of #66, which was prematurely closed.

The current code overwrites any pre-existing default native exception handler. They should be saved and called by the newly created handler.

PR #67 fixes a similar issue for Android but this issue is for iOS.

JS error handler receives a TypeError on iOS as error message

Here's what I'm doing to raise a JS error :- throw new Error('Custom error');

Here's my JS errorHandler :-

const errorHandler = async (e) => {
  await appendToLog(e.message);
  Alert.alert(
    `An error occurred`,
    `Error: ${e.name} ${e.message}`,
    [
      { text: `OK`, onPress: () => { BackHandler.exitApp(); } },
      { text: `Copy Error`, onPress: async () => { await Clipboard.setString(e.message); } },
    ],
    { cancelable: false },
  );
};
setJSExceptionHandler(errorHandler, true);

Here's the output on android :-
screen shot 2018-05-09 at 9 31 32 pm
Works as expected.

Here's the issue, the output on iOS :-
screen shot 2018-05-09 at 9 58 48 pm

Could you please look into this ASAP and resolve it or provide me with a work around to fix it?
Thank you.

Not catching anything, what am I missing?

I placed the template code for both JS and NativeExceptions in my index.js and then threw a variety of js and native errors throughout the app and nothing registers. I tried placing the listeners in different places, and still nothing. I have linked everything and followed the directions completely. What am I missing?

Not able to get custom error message in dev mode in genymotion android simulator or bundle mode

import React from 'react';
import {Text, View, StyleSheet, Button,Alert, TouchableOpacity,NativeModules} from 'react-native';

import {setJSExceptionHandler,getJSExceptionHandler} from 'react-native-exception-handler';

const {ReactNativeExceptionHandler} = NativeModules;



const errorHandler = (e, isFatal) =>{

    console.log("xxxxxx");
    console.warn("YYYYYYYY");

    Alert.alert(
        'Sorry ',
        ` Error :${(isFatal)? 'Fatal':''} ${e.name} ${e.message}
        we have reported to the team!
        `
            [
        {text: 'OK'}
            ],
        { cancelable: false }
    )

}
setJSExceptionHandler(errorHandler,true);


ReactNativeExceptionHandler.setHandlerforNativeException( true  ,(value) =>{
    console.warn("Happy bahg jaye gii");
    console.log("Happy bahg jaye gii");
});




class JSErrorHandler extends React.Component{
    constructor(props){
        super(props);
    }
    render(){
        return(
            <View style = {styles.container}>
                <Text> Here will be fun </Text>
                  <TouchableOpacity onPress={()=>{
                          this.test()
                      }}>
                      <Text>hello</Text>
                  </TouchableOpacity>
            </View>
        )
    }
}

const styles = StyleSheet.create({
    container : {
        flex:1,
        justifyContent:"center"
    }
})

export default  JSErrorHandler;

Can we record the current JS state in to error report?

Dear Author,

This plugin is working perfectly. Only thing I am wondering is can we record Javascript state in the part of error message as well? Otherwise it is hard to find out with just the title line of error message.

Thanks

Question: Way to defy exit?

Hi! I'm researching this topic and I have to say this lib is brilliant! As I dig through the code I enjoy the choices you've made, and how extensive your v2 is!

I was wondering. Have you considered, and I might have just missed this, a way to have the app automatically re-launch or even ignore on an error? That way a failure would be reported but the user would not have to close and re-open the app?

Thanks!

Undefined instead of error and isFatal params

I get undefined instead of normal values in error and isFatal callback's params.

code:

setJSExceptionHandler((error, isFatal) => {
  console.log('my error: ', error);
  console.log('my isFatal: ', isFatal);
}, true);
console.log('setJSExceptionHandler(): ', getJSExceptionHandler());

console.log:

setJSExceptionHandler():  function (error, isFatal) {
    console.log('my error: ', error);
    console.log('my isFatal: ', isFatal);
  }

my error:  undefined
my isFatal:  undefined

I tried to call an error by:

throw new Error('Custom error');

and call method from undefined params of object...

UPDATED:
This happens when I call an error from a component of React. If I call error in index.js file then works fine...

I changed in method setJSExceptionHandler row 17 by folow (added console.logs)

console.error = (message, error) => {
      console.log('global.ErrorUtils.reportError, message: ', message);
      console.log('global.ErrorUtils.reportError, error: ', error);
      global.ErrorUtils.reportError(error)
    }; // sending console.error so that it can be caught

and message I get with data, but error is undefined...

UPDATED2:

This happens when I call Error from react component. And it works normal if I call in the same file(index.js of App.js)...

"react": "^16.3.1",
"react-native": "^0.55.4",
"react-native-exception-handler": "^2.8.6",

Not able to customize NativeException on android

Hi.
I have a little problem. I try to replace error screen on Android. I've copied DefaultErrorScreen and renamed to CustomErrorScreen and default_error_screen.xml and added a method onCreate to MainApplication

@Override
public void onCreate() {
    super.onCreate();
    //This will replace the native error handler popup with your own custom activity.
    ReactNativeExceptionHandlerModule.replaceErrorScreenActivityClass(CustomErrorScreen.class);
}

into the console I can see:

03-04 16:15:03.773 1720-1963/system_process I/ActivityManager: START u0 {flg=0x10000000 cmp=ru.application.***/ru.***.CustomErrorScreen (has extras)} from uid 10089 on display 0

But nothing happens I just see a previous screen, when an error occurred and I'm not able to tape on any element on the screen.
And if comment this line ReactNativeExceptionHandlerModule.replaceErrorScreenActivityClass(CustomErrorScreen.class); your default error screen turns up without any problem.
What I do wrong?

Does this library interfere with other crash reporters

After enabling native error handling, Bugsnag stopped reporting native crashes. The custom native exception handler works, and i can manually pass some of the error to Bugsnag, like this:

setNativeExceptionHandler((exceptionString) => {
       bugsnag.notify( Error("NativeExceptionHandler caught: " + String(exceptionString)) );
 });

But that report is limited. First of all, exceptionString is truncated and second, Bugsnag loses the ability to match the error to a line of code (which they do via dsyms).

Is there a way to still display a message on native exceptions but also allow other registered handlers to do their work?

Thank you for your contribution. This is a good lib 👍

Exception handler with redux

Anybody have luck with using handler with redux? I've tried putting the handler inside a Redux connected component before doing setJSExceptionHandler and I'm have issues with the store not updating on next app start.

Js exeception not caught in dev mode until first render

Hi,

i'm trying to integrate this module

In index.js (main entrypoint)

import {
    AppRegistry
} from 'react-native';
import App from './App';

import {
    Alert
} from 'react-native';
import {
    setJSExceptionHandler,
    getJSExceptionHandler
} from 'react-native-exception-handler';
import {
    setNativeExceptionHandler
} from 'react-native-exception-handler';

const errorHandler = (e, isFatal) => {

    console.log('------------------- JS HANDLER ------------------');
console.log('------------------- CUSTOM JS HANDLER ------------------');
    console.log(error);

    if (isFatal) {
        Alert.alert(
            'Unexpected error occurred',
            `
          Error: ${(isFatal) ? 'Fatal:' : ''} ${e.name} ${e.message}
  
          We will need to restart the app.
          `, [{
                text: 'Restart',
                onPress: () => {
                    //RNRestart.Restart();
                }
            }]
        );
    } else {
        console.log(e); // So that we can see it in the ADB logs in case of Android if needed
    }
};

const setNativeHandler = (exceptionString) => {

    console.log('------------------- NATIVE HANDLER ------------------');
    console.log(exceptionString);
};

console.log('------------------- JS HANDLER ------------------');
console.log('Entering exception handling');

setJSExceptionHandler(errorHandler, true);

setNativeExceptionHandler(setNativeHandler, false);

AppRegistry.registerComponent('TruckyV2', () => App);

In adb log i see

------------------- JS HANDLER ------------------ Entering exception handling

Don't see ------------------- CUSTOM JS HANDLER ------------------

In Home.js constructor (called from App), i've added this.test() to force fire error, continue to see the RN default red screeen

screenshot_1525254292

What's wrong?

"react": "^16.3.1",
"react-native": "^0.55.3",
"react-native-exception-handler": "^2.7.5",

Thanks

2.8.5: Infinite recursion/crash

With the latest version (2.8.5), our app started crashing as soon as an error occurred. I’m guessing that the issue is that the handler ends up recursing on itself (maybe it somehow gets registered twice?). I don’t know exactly why and don’t have the time right now to look deeply into it (I will just pin the version to 2.7.5, which works fine), but it is definitely react-native-exception-handler 2.7.5 -> 2.8.5 that causes the crash.

06-01 17:07:26.802 13325-13365/co.elk.rn E/ReactNativeJNI: Got JS Exception: Exception calling object as function: Maximum call stack size exceeded. (<unknown file>:16)
    Got JS Stack: l@[native code]
    index.android.bundle:16:385
    [email protected]:5:141
    [email protected]:787:857
    [email protected]:504:245
    l@[native code]
    index.android.bundle:16:385
    [email protected]:5:141
    [email protected]:787:857
    [email protected]:504:245
    l@[native code]
    index.android.bundle:16:385
    [email protected]:5:141
    [email protected]:787:857
    [email protected]:504:245
    l@[native code]
    index.android.bundle:16:385
    [email protected]:5:141
    [email protected]:787:857
    [email protected]:504:245
    l@[native code]
    index.android.bundle:16:385
    [email protected]:5:141
    [email protected]:787:857
    [email protected]:504:245
    l@[native code]
    index.android.bundle:16:385
    [email protected]:5:141
    [email protected]:787:857
    [email protected]:504:245
    l@[native code]
    index.android.bundle:16:385
    reportError@index
06-01 17:07:26.803 13325-13365/co.elk.rn E/AndroidRuntime: FATAL EXCEPTION: mqt_js
    Process: co.elk.rn, PID: 13325
    java.lang.RuntimeException: Error calling JSTimers.callTimers
        at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
        at android.os.Handler.handleCallback(Handler.java:751)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
        at android.os.Looper.loop(Looper.java:154)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
        at java.lang.Thread.run(Thread.java:761)
     Caused by: com.facebook.jni.CppException: Exception calling object as function: Maximum call stack size exceeded. (<unknown file>:16)
        at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) 
        at android.os.Handler.handleCallback(Handler.java:751) 
        at android.os.Handler.dispatchMessage(Handler.java:95) 
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29) 
        at android.os.Looper.loop(Looper.java:154) 
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192) 
        at java.lang.Thread.run(Thread.java:761) 

Callback of setNativeExceptionHandler isn't called

Hi @master-atul,

I'm inducing a native crash by calling RnTestExceptionHandler.raiseTestNativeError() when I click a button in my app. The error alert (see image below) shows up but the callback doesn't appear to be called.

Setup:

setNativeExceptionHandler((error) => {
  // This method is never called.
})

I'm not using Wix and the callback isn't called when I add false as the second argument either:

setNativeExceptionHandler((error) => {
  // This method is never called.
}, false)

Any idea what I might be doing wrong?

I'm using:

"react-native": "0.53.0",
"react-native-exception-handler": "2.7.1",

android_native_exception

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.