mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Record latest error type in dev support
Summary: In DevSupportManagerBase.java->updateLastErrorInfo(), errorType was not recorded like errorMessage and errorStack, we could either remove errorType as a parameter or recorded it for future use. This diff recorded it since it would make the error info complete. Changelog: [Android][Changed] - Record latest error type in dev support Reviewed By: PeteTheHeat Differential Revision: D26884647 fbshipit-source-id: 712d82667bdc4b3410f4c83a3df9a456af6d9061
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ba61267015
commit
423453e105
+10
-8
@@ -48,6 +48,7 @@ import com.facebook.react.devsupport.interfaces.DevOptionHandler;
|
||||
import com.facebook.react.devsupport.interfaces.DevSplitBundleCallback;
|
||||
import com.facebook.react.devsupport.interfaces.DevSupportManager;
|
||||
import com.facebook.react.devsupport.interfaces.ErrorCustomizer;
|
||||
import com.facebook.react.devsupport.interfaces.ErrorType;
|
||||
import com.facebook.react.devsupport.interfaces.PackagerStatusCallback;
|
||||
import com.facebook.react.devsupport.interfaces.StackFrame;
|
||||
import com.facebook.react.modules.core.RCTNativeAppEventEmitter;
|
||||
@@ -85,12 +86,6 @@ public abstract class DevSupportManagerBase
|
||||
"flipper://null/Hermesdebuggerrn?device=React%20Native";
|
||||
private static final String FLIPPER_DEVTOOLS_URL = "flipper://null/React?device=React%20Native";
|
||||
private boolean mIsSamplingProfilerEnabled = false;
|
||||
|
||||
private enum ErrorType {
|
||||
JS,
|
||||
NATIVE
|
||||
}
|
||||
|
||||
private static final String EXOPACKAGE_LOCATION_FORMAT =
|
||||
"/data/local/tmp/exopackage/%s//secondary-dex";
|
||||
|
||||
@@ -124,6 +119,7 @@ public abstract class DevSupportManagerBase
|
||||
private @Nullable RedBoxHandler mRedBoxHandler;
|
||||
private @Nullable String mLastErrorTitle;
|
||||
private @Nullable StackFrame[] mLastErrorStack;
|
||||
private @Nullable ErrorType mLastErrorType;
|
||||
private int mLastErrorCookie = 0;
|
||||
private @Nullable DevBundleDownloadListener mBundleDownloadListener;
|
||||
private @Nullable List<ErrorCustomizer> mErrorCustomizers;
|
||||
@@ -353,7 +349,7 @@ public abstract class DevSupportManagerBase
|
||||
updateLastErrorInfo(message, stack, errorCookie, ErrorType.JS);
|
||||
// JS errors are reported here after source mapping.
|
||||
if (mRedBoxHandler != null) {
|
||||
mRedBoxHandler.handleRedbox(message, stack, RedBoxHandler.ErrorType.JS);
|
||||
mRedBoxHandler.handleRedbox(message, stack, ErrorType.JS);
|
||||
mRedBoxDialog.resetReporting();
|
||||
}
|
||||
mRedBoxDialog.show();
|
||||
@@ -420,7 +416,7 @@ public abstract class DevSupportManagerBase
|
||||
// Only report native errors here. JS errors are reported
|
||||
// inside {@link #updateJSError} after source mapping.
|
||||
if (mRedBoxHandler != null && errorType == ErrorType.NATIVE) {
|
||||
mRedBoxHandler.handleRedbox(message, stack, RedBoxHandler.ErrorType.NATIVE);
|
||||
mRedBoxHandler.handleRedbox(message, stack, ErrorType.NATIVE);
|
||||
}
|
||||
mRedBoxDialog.resetReporting();
|
||||
mRedBoxDialog.show();
|
||||
@@ -1002,6 +998,11 @@ public abstract class DevSupportManagerBase
|
||||
return mLastErrorStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable ErrorType getLastErrorType() {
|
||||
return mLastErrorType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPackagerConnected() {
|
||||
// No-op
|
||||
@@ -1083,6 +1084,7 @@ public abstract class DevSupportManagerBase
|
||||
mLastErrorTitle = message;
|
||||
mLastErrorStack = stack;
|
||||
mLastErrorCookie = errorCookie;
|
||||
mLastErrorType = errorType;
|
||||
}
|
||||
|
||||
private void reloadJSInProxyMode() {
|
||||
|
||||
+6
@@ -16,6 +16,7 @@ import com.facebook.react.devsupport.interfaces.DevOptionHandler;
|
||||
import com.facebook.react.devsupport.interfaces.DevSplitBundleCallback;
|
||||
import com.facebook.react.devsupport.interfaces.DevSupportManager;
|
||||
import com.facebook.react.devsupport.interfaces.ErrorCustomizer;
|
||||
import com.facebook.react.devsupport.interfaces.ErrorType;
|
||||
import com.facebook.react.devsupport.interfaces.PackagerStatusCallback;
|
||||
import com.facebook.react.devsupport.interfaces.StackFrame;
|
||||
import com.facebook.react.modules.debug.interfaces.DeveloperSettings;
|
||||
@@ -154,6 +155,11 @@ public class DisabledDevSupportManager implements DevSupportManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable ErrorType getLastErrorType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerErrorCustomizer(ErrorCustomizer errorCustomizer) {}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ package com.facebook.react.devsupport;
|
||||
import android.content.Context;
|
||||
import android.text.SpannedString;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.react.devsupport.interfaces.ErrorType;
|
||||
import com.facebook.react.devsupport.interfaces.StackFrame;
|
||||
|
||||
/**
|
||||
@@ -18,21 +19,6 @@ import com.facebook.react.devsupport.interfaces.StackFrame;
|
||||
* setRedBoxHandler in ReactInstanceManager.
|
||||
*/
|
||||
public interface RedBoxHandler {
|
||||
enum ErrorType {
|
||||
JS("JS"),
|
||||
NATIVE("Native");
|
||||
|
||||
private final String name;
|
||||
|
||||
ErrorType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
/** Callback interface for {@link #reportRedbox}. */
|
||||
interface ReportCompletedListener {
|
||||
void onReportSuccess(SpannedString spannedString);
|
||||
|
||||
+3
@@ -90,6 +90,9 @@ public interface DevSupportManager extends NativeModuleCallExceptionHandler {
|
||||
@Nullable
|
||||
StackFrame[] getLastErrorStack();
|
||||
|
||||
@Nullable
|
||||
ErrorType getLastErrorType();
|
||||
|
||||
void registerErrorCustomizer(ErrorCustomizer errorCustomizer);
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.devsupport.interfaces;
|
||||
|
||||
public enum ErrorType {
|
||||
JS("JS"),
|
||||
NATIVE("Native");
|
||||
|
||||
private final String name;
|
||||
|
||||
ErrorType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user