Skip to content

Commit

Permalink
Enable Logging information from redboxes in Android Ads Manager to Scuba
Browse files Browse the repository at this point in the history
Reviewed By: mkonicek

Differential Revision: D3433990

fbshipit-source-id: 54fa60fa746c9d0d834f86b7dd2e3ef18a694a32
  • Loading branch information
Siqi Liu authored and Facebook Github Bot committed Jun 18, 2016
1 parent c6020a0 commit ee0333c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ public class DevSupportManagerImpl implements DevSupportManager {

private static final int JAVA_ERROR_COOKIE = -1;
private static final String JS_BUNDLE_FILE_NAME = "ReactNativeDevBundle.js";
private static enum ErrorType {
JS,
NATIVE
}

private static final String EXOPACKAGE_LOCATION_FORMAT
= "/data/local/tmp/exopackage/%s//secondary-dex";
Expand Down Expand Up @@ -184,7 +188,7 @@ public void handleException(Exception e) {

@Override
public void showNewJavaError(String message, Throwable e) {
showNewError(message, StackTraceHelper.convertJavaStackTrace(e), JAVA_ERROR_COOKIE);
showNewError(message, StackTraceHelper.convertJavaStackTrace(e), JAVA_ERROR_COOKIE, ErrorType.NATIVE);
}

/**
Expand All @@ -201,7 +205,7 @@ public void addCustomDevOption(

@Override
public void showNewJSError(String message, ReadableArray details, int errorCookie) {
showNewError(message, StackTraceHelper.convertJsStackTrace(details), errorCookie);
showNewError(message, StackTraceHelper.convertJsStackTrace(details), errorCookie, ErrorType.JS);
}

@Override
Expand All @@ -224,8 +228,9 @@ public void run() {
StackFrame[] stack = StackTraceHelper.convertJsStackTrace(details);
mRedBoxDialog.setExceptionDetails(message, stack);
mRedBoxDialog.setErrorCookie(errorCookie);
// JS errors are reported here after source mapping.
if (mRedBoxHandler != null) {
mRedBoxHandler.handleRedbox(message, stack);
mRedBoxHandler.handleRedbox(message, stack, RedBoxHandler.ErrorType.JS);
}
mRedBoxDialog.show();
}
Expand All @@ -243,7 +248,8 @@ public void hideRedboxDialog() {
private void showNewError(
final String message,
final StackFrame[] stack,
final int errorCookie) {
final int errorCookie,
final ErrorType errorType) {
UiThreadUtil.runOnUiThread(
new Runnable() {
@Override
Expand All @@ -259,8 +265,10 @@ public void run() {
}
mRedBoxDialog.setExceptionDetails(message, stack);
mRedBoxDialog.setErrorCookie(errorCookie);
if (mRedBoxHandler != null) {
mRedBoxHandler.handleRedbox(message, stack);
// 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);
}
mRedBoxDialog.show();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,17 @@
* The implementation should be passed by {@link #setRedBoxHandler} in {@link ReactInstanceManager}.
*/
public interface RedBoxHandler {
void handleRedbox(String title, StackFrame[] stack);
enum ErrorType {
JS("JS"),
NATIVE("Native");

private final String name;
ErrorType(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
void handleRedbox(String title, StackFrame[] stack, ErrorType errorType);
}

0 comments on commit ee0333c

Please sign in to comment.