You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{ExceptionsManager}from'react-native';global.ErrorUtils.setGlobalHandler((e,isFatal)=>{if(__DEV__){// In DEV, pass the error to the standard ExceptionsManager// This way you'll still get nice RSODs in DEVExceptionsManager.handleException(e,isFatal);}else{// Not in DEV. Send the exception 'e' to your logger of choicesendErrorToCrashReporter(e.message);}});
NOTE:setGlobalHandler does not catch native iOS and Android exceptions. Without further action if, e.g., sendErrorToCrashReporter throws, the app will crash with no useful feedback to the user. In order to handle native exceptions gracefully with enhanced user experience, consider something like react-native-exception-handler, maybe fork it or develop our own custom solution.
See
global.ErrorUtils.setGlobalHandler
.Example:
I'm not sure whether React Native exports
ExceptionsManager
, but it can be found at https://github.com/facebook/react-native/blob/7d1d4dc0645a5dfecc53d05b16338f9c08cc0d0f/ReactAndroid/src/main/java/com/facebook/react/modules/core/ExceptionsManagerModule.javaNOTE:
setGlobalHandler
does not catch native iOS and Android exceptions. Without further action if, e.g.,sendErrorToCrashReporter
throws, the app will crash with no useful feedback to the user. In order to handle native exceptions gracefully with enhanced user experience, consider something likereact-native-exception-handler
, maybe fork it or develop our own custom solution.References:
The text was updated successfully, but these errors were encountered: