mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-01-31 09:08:48 +08:00
Simplify logging exceptions from JS to native
Reviewed By: vjeux Differential Revision: D2615559 fb-gh-sync-id: ee931b3691251c8b6276699c6f927e47d8e8fd97
This commit is contained in:
committed by
facebook-github-bot-5
parent
d9b4c57e12
commit
0c83407dd2
@@ -32,12 +32,10 @@ if (typeof window === 'undefined') {
|
||||
window = GLOBAL;
|
||||
}
|
||||
|
||||
function handleError(e, isFatal) {
|
||||
try {
|
||||
require('ExceptionsManager').handleException(e, isFatal);
|
||||
} catch(ee) {
|
||||
console.log('Failed to print error: ', ee.message);
|
||||
}
|
||||
function setUpConsole() {
|
||||
// ExceptionsManager transitively requires Promise so we install it after
|
||||
var ExceptionsManager = require('ExceptionsManager');
|
||||
ExceptionsManager.installConsoleErrorReporter();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,21 +70,19 @@ function polyfillGlobal(name, newValue, scope=GLOBAL) {
|
||||
Object.defineProperty(scope, name, {...descriptor, value: newValue});
|
||||
}
|
||||
|
||||
function setUpRedBoxErrorHandler() {
|
||||
function setUpErrorHandler() {
|
||||
function handleError(e, isFatal) {
|
||||
try {
|
||||
require('ExceptionsManager').handleException(e, isFatal);
|
||||
} catch(ee) {
|
||||
console.log('Failed to print error: ', ee.message);
|
||||
}
|
||||
}
|
||||
|
||||
var ErrorUtils = require('ErrorUtils');
|
||||
ErrorUtils.setGlobalHandler(handleError);
|
||||
}
|
||||
|
||||
function setUpRedBoxConsoleErrorHandler() {
|
||||
// ExceptionsManager transitively requires Promise so we install it after
|
||||
var ExceptionsManager = require('ExceptionsManager');
|
||||
var Platform = require('Platform');
|
||||
// TODO (#6925182): Enable console.error redbox on Android
|
||||
if (__DEV__ && Platform.OS === 'ios') {
|
||||
ExceptionsManager.installConsoleErrorReporter();
|
||||
}
|
||||
}
|
||||
|
||||
function setUpFlowChecker() {
|
||||
if (__DEV__) {
|
||||
var checkFlowAtRuntime = require('checkFlowAtRuntime');
|
||||
@@ -187,12 +183,12 @@ function setUpDevTools() {
|
||||
}
|
||||
|
||||
setUpProcessEnv();
|
||||
setUpRedBoxErrorHandler();
|
||||
setUpConsole();
|
||||
setUpTimers();
|
||||
setUpAlert();
|
||||
setUpPromise();
|
||||
setUpErrorHandler();
|
||||
setUpXHR();
|
||||
setUpRedBoxConsoleErrorHandler();
|
||||
setUpGeolocation();
|
||||
setUpWebSockets();
|
||||
setUpProfile();
|
||||
|
||||
Reference in New Issue
Block a user