How to use react-native-exception-handler - 10 common examples

To help you get started, we’ve selected a few react-native-exception-handler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github berty / berty / client / react-native / app / common / helpers / crash-handler.js View on Github external
{ cancelable: false }
  )
}

if (!isIntegrationMode) {
  // eslint-disable-next-line
  if (!__DEV__) {
    console.error = error => exceptionHandler(error, false)
  }

  if (Platform.OS === 'ios' || Platform.OS === 'android') {
    const allowInDevMode = false
    const forceAppQuit = false
    const executeDefaultHandler = false

    setJSExceptionHandler(exceptionHandler, allowInDevMode)
    setNativeExceptionHandler(() => {}, forceAppQuit, executeDefaultHandler)
  }
}
github HenryQuan / WoWs-Info-Re / WoWsInfo / src / app.js View on Github external
import { withTheme, DarkTheme, DefaultTheme } from 'react-native-paper';
import { Menu, Settings, About, Setup, Consumable, CommanderSkill, 
  BasicDetail, Achievement, Map as GameMap, Collection, Warship, WarshipDetail, 
  WarshipFilter, WarshipModule, Loading, Statistics, ClanInfo, PlayerAchievement, 
  Rating, Search, Graph, SimilarGraph, License, RS, SupportMe, ProVersion } from './page';
import { LOCAL, getFirstLaunch, getCurrServer, APP } from './value/data';
import { DataLoader, Downloader } from './core';
import { GREY, BLUE } from 'react-native-material-color';
import { TintColour } from './value/colour';
import { lang } from './value/lang';
import { PlayerShip } from './page/player/PlayerShip';
import { Detailed } from './page/player/Detailed';
import { Rank } from './page/player/Rank';
import { setJSExceptionHandler, setNativeExceptionHandler } from 'react-native-exception-handler';

setJSExceptionHandler((e, fatal) => {
  if (fatal) {
    showAlert(`${e.name}\n${e.message}`, 'JS');
  } else {
    console.log(`JSException\n${e}`);
  }
}, true);

setNativeExceptionHandler((e) => {
  showAlert(e, 'NATIVE');
  console.log(`NativeException\n${e}`);
});

// Ask user to email me the log
function showAlert(msg, mode) {
  Alert.alert(`FATAL ${mode} ERROR`, `${msg}\n\nPlease contact developer`,
    [{
github berty / berty / client / react-native / common / helpers / crash-handler.js View on Github external
{ cancelable: false }
  )
}

if (process.env['ENVIRONMENT'] !== 'integration_test') {
  // eslint-disable-next-line
  if (!__DEV__) {
    console.error = error => exceptionHandler(error, false)
  }

  if (Platform.OS === 'ios' || Platform.OS === 'android') {
    const allowInDevMode = false
    const forceAppQuit = false
    const executeDefaultHandler = false

    setJSExceptionHandler(exceptionHandler, allowInDevMode)
    setNativeExceptionHandler(() => {}, forceAppQuit, executeDefaultHandler)
  }
}
github berty / berty / client / react-native / common / helpers / crash-handler.js View on Github external
)
}

if (process.env['ENVIRONMENT'] !== 'integration_test') {
  // eslint-disable-next-line
  if (!__DEV__) {
    console.error = error => exceptionHandler(error, false)
  }

  if (Platform.OS === 'ios' || Platform.OS === 'android') {
    const allowInDevMode = false
    const forceAppQuit = false
    const executeDefaultHandler = false

    setJSExceptionHandler(exceptionHandler, allowInDevMode)
    setNativeExceptionHandler(() => {}, forceAppQuit, executeDefaultHandler)
  }
}
github berty / berty / client / react-native / app / common / helpers / crash-handler.js View on Github external
)
}

if (!isIntegrationMode) {
  // eslint-disable-next-line
  if (!__DEV__) {
    console.error = error => exceptionHandler(error, false)
  }

  if (Platform.OS === 'ios' || Platform.OS === 'android') {
    const allowInDevMode = false
    const forceAppQuit = false
    const executeDefaultHandler = false

    setJSExceptionHandler(exceptionHandler, allowInDevMode)
    setNativeExceptionHandler(() => {}, forceAppQuit, executeDefaultHandler)
  }
}
github wuyanwuyan / react_native_app_start_kit / index.js View on Github external
import { AppRegistry } from 'react-native';
import App from './src/index';

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

const customErrorHandler = (error, isFatal) => {
    // Logic for reporting to devs
    // Example : Log issues to github issues using github apis.

    console.log(error, isFatal); // example

};

const previousErrorHandler = getJSExceptionHandler(); // by default u will get the red screen error handler here

const errorHandler = (e, isFatal) => {
    customErrorHandler(e, isFatal);
    previousErrorHandler(e, isFatal);
};

// We will still see the error screen, but our customErrorHandler() function will be called
setJSExceptionHandler(errorHandler);


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.
github berty / berty / client / packages / common / helpers / crash-handler.js View on Github external
!isFatal && { text: I18n.t('cancel') },
    ],
    { cancelable: false }
  )
}

if (!isIntegrationMode && Platform.OS !== 'web') {
  if (!__DEV__) {
    console.error = error => exceptionHandler(error, false)
  }

  const allowInDevMode = false
  const forceAppQuit = false
  const executeDefaultHandler = true

  setJSExceptionHandler(exceptionHandler, allowInDevMode)
  setNativeExceptionHandler(
    () =>
      Notifier.system({
        title: I18n.t('restart'),
        body: I18n.t('unexpected-error'),
      }),
    forceAppQuit,
    executeDefaultHandler
  )
}
github berty / berty / client / packages / common / helpers / crash-handler.js View on Github external
],
    { cancelable: false }
  )
}

if (!isIntegrationMode && Platform.OS !== 'web') {
  if (!__DEV__) {
    console.error = error => exceptionHandler(error, false)
  }

  const allowInDevMode = false
  const forceAppQuit = false
  const executeDefaultHandler = true

  setJSExceptionHandler(exceptionHandler, allowInDevMode)
  setNativeExceptionHandler(
    () =>
      Notifier.system({
        title: I18n.t('restart'),
        body: I18n.t('unexpected-error'),
      }),
    forceAppQuit,
    executeDefaultHandler
  )
}
github lbryio / lbry-android / app / src / index.js View on Github external
import { persistStore, autoRehydrate } from 'redux-persist';
import AsyncStorage from '@react-native-community/async-storage';
import FilesystemStorage from 'redux-persist-filesystem-storage';
import createCompressor from 'redux-persist-transform-compress';
import createFilter from 'redux-persist-transform-filter';
import moment from 'moment';
import drawerReducer from 'redux/reducers/drawer';
import settingsReducer from 'redux/reducers/settings';
import thunk from 'redux-thunk';

const globalExceptionHandler = (error, isFatal) => {
  if (error && NativeModules.Firebase) {
    NativeModules.Firebase.logException(isFatal, error.message ? error.message : 'No message', JSON.stringify(error));
  }
};
setJSExceptionHandler(globalExceptionHandler, true);

function isFunction(object) {
  return typeof object === 'function';
}

function isNotFunction(object) {
  return !isFunction(object);
}

function createBulkThunkMiddleware() {
  return ({ dispatch, getState }) => next => action => {
    if (action.type === 'BATCH_ACTIONS') {
      action.actions.filter(isFunction).map(actionFn => actionFn(dispatch, getState));
    }
    return next(action);
  };
github UCSD / campus-mobile / app / App.js View on Github external
finishLoading = () => {
		this.setState({ isLoading: false })
		const errorHandler = (e, isFatal) => {
			if (isFatal) {
				gracefulFatalReset(new Error('Crash: ' + e.name + ': ' + e.message + ': ' + e.stack))
			}
		}
		setJSExceptionHandler(errorHandler, true)
	}

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
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis