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:
Lulu Wu
2021-10-08 11:08:43 -07:00
committed by Facebook GitHub Bot
parent b14b34b232
commit c901c43d11
7 changed files with 290 additions and 186 deletions
@@ -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);
}
}
}