mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Remove shared responsibility between LogBox and ExceptionsManager native module
Summary: ## Context Right now we are using both LogBox and ExceptionsManager native module to report JS errors in ExceptionsManager.js, from below code we can tell they have some overlapping - when ```__DEV__ === true``` both could report the error. https://www.internalfb.com/code/fbsource/[5fb44bc926de87e62e6e538082496f22017698eb]/xplat/js/react-native-github/Libraries/Core/ExceptionsManager.js?lines=109-141 ## Changes In this diff overlapping is removed: in ```ExceptionsManager.js``` LogBox will be responsible for showing the error with dialog when ```__DEV__ === true```, when it's prod we'll use ExceptionsManager native module to report the error. As a result LogBox and ExceptionsManager native module don't share responsibilities any more. Changelog: [General][Changed] - Remove shared responsibility between LogBox and ExceptionsManager native module Reviewed By: philIip Differential Revision: D30942433 fbshipit-source-id: 8fceaaa431e5a460c0ccd151fe9831dcccbcf237
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b14b34b232
commit
c901c43d11
+7
-19
@@ -65,28 +65,16 @@ public class ExceptionsManagerModule extends NativeExceptionsManagerSpec {
|
||||
public void reportException(ReadableMap data) {
|
||||
String message = data.hasKey("message") ? data.getString("message") : "";
|
||||
ReadableArray stack = data.hasKey("stack") ? data.getArray("stack") : Arguments.createArray();
|
||||
int id = data.hasKey("id") ? data.getInt("id") : -1;
|
||||
boolean isFatal = data.hasKey("isFatal") ? data.getBoolean("isFatal") : false;
|
||||
|
||||
if (mDevSupportManager.getDevSupportEnabled()) {
|
||||
boolean suppressRedBox = false;
|
||||
if (data.getMap("extraData") != null && data.getMap("extraData").hasKey("suppressRedBox")) {
|
||||
suppressRedBox = data.getMap("extraData").getBoolean("suppressRedBox");
|
||||
}
|
||||
|
||||
if (!suppressRedBox) {
|
||||
mDevSupportManager.showNewJSError(message, stack, id);
|
||||
}
|
||||
String extraDataAsJson = ExceptionDataHelper.getExtraDataAsJson(data);
|
||||
if (isFatal) {
|
||||
throw new JavascriptException(JSStackTrace.format(message, stack))
|
||||
.setExtraDataAsJson(extraDataAsJson);
|
||||
} else {
|
||||
String extraDataAsJson = ExceptionDataHelper.getExtraDataAsJson(data);
|
||||
if (isFatal) {
|
||||
throw new JavascriptException(JSStackTrace.format(message, stack))
|
||||
.setExtraDataAsJson(extraDataAsJson);
|
||||
} else {
|
||||
FLog.e(ReactConstants.TAG, JSStackTrace.format(message, stack));
|
||||
if (extraDataAsJson != null) {
|
||||
FLog.d(ReactConstants.TAG, "extraData: %s", extraDataAsJson);
|
||||
}
|
||||
FLog.e(ReactConstants.TAG, JSStackTrace.format(message, stack));
|
||||
if (extraDataAsJson != null) {
|
||||
FLog.d(ReactConstants.TAG, "extraData: %s", extraDataAsJson);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user