Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
ReactNative ErrorHandling Example - From
const defaultHandler = (ErrorUtils.getGlobalHandler && ErrorUtils.getGlobalHandler()) || ErrorUtils._globalHandler;
const customErrorHandler = async (err, isFatal) => {
await AsyncStorage.setItem('lastError', JSON.stringify(err, Object.getOwnPropertyNames(err)));
return defaultHandler(err, isFatal);
//inside the App component:
async componentWillMount() {
const lastError = await AsyncStorage.getItem('lastError');
// dispatch error to logs
if (lastError) {
sender: 'mobile-ops',
message: 'Fatal error !',
info: {
error: lastError
await AsyncStorage.removeItem('lastError');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.