Send notifications on litho's error boundary
Summary: Sends notifications to crash reportr plugin whenever the error boundary happens Reviewed By: danielbuechele Differential Revision: D13307473 fbshipit-source-id: dc0c6d2ebac32881fdb1aa5f63def824a115cf9e
This commit is contained in:
committed by
Facebook Github Bot
parent
d331ec2f10
commit
9cfa1b3074
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* <p>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.flipper.sample;
|
||||
|
||||
@@ -65,7 +64,7 @@ public class FlipperSampleApplication extends Application {
|
||||
new SharedPreferencesDescriptor("other_sample", Context.MODE_PRIVATE))));
|
||||
client.addPlugin(new LeakCanaryFlipperPlugin());
|
||||
client.addPlugin(new ExampleFlipperPlugin());
|
||||
client.addPlugin(new CrashReporterPlugin());
|
||||
client.addPlugin(CrashReporterPlugin.getInstance());
|
||||
client.start();
|
||||
|
||||
getSharedPreferences("sample", Context.MODE_PRIVATE).edit().putString("Hello", "world").apply();
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* <p>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.flipper.plugins.crashreporter;
|
||||
|
||||
@@ -22,7 +21,16 @@ public class CrashReporterPlugin implements FlipperPlugin {
|
||||
@Nullable private FlipperConnection mConnection;
|
||||
|
||||
@Nullable private Thread.UncaughtExceptionHandler prevHandler;
|
||||
private static CrashReporterPlugin crashreporterPlugin = null;
|
||||
|
||||
private CrashReporterPlugin() {}
|
||||
|
||||
// static method to create instance of Singleton class
|
||||
public static CrashReporterPlugin getInstance() {
|
||||
if (crashreporterPlugin == null) crashreporterPlugin = new CrashReporterPlugin();
|
||||
|
||||
return crashreporterPlugin;
|
||||
}
|
||||
/*
|
||||
* Activity to be used to display incoming messages
|
||||
*/
|
||||
@@ -38,6 +46,15 @@ public class CrashReporterPlugin implements FlipperPlugin {
|
||||
new Thread.UncaughtExceptionHandler() {
|
||||
@Override
|
||||
public void uncaughtException(Thread paramThread, Throwable paramThrowable) {
|
||||
sendExceptionMessage(paramThread, paramThrowable);
|
||||
if (prevHandler != null) {
|
||||
prevHandler.uncaughtException(paramThread, paramThrowable);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void sendExceptionMessage(Thread paramThread, Throwable paramThrowable) {
|
||||
if (mConnection != null) {
|
||||
FlipperConnection connection = mConnection;
|
||||
FlipperArray.Builder builder = new FlipperArray.Builder();
|
||||
@@ -53,11 +70,6 @@ public class CrashReporterPlugin implements FlipperPlugin {
|
||||
.put("reason", paramThrowable.getMessage())
|
||||
.build());
|
||||
}
|
||||
if (prevHandler != null) {
|
||||
prevHandler.uncaughtException(paramThread, paramThrowable);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user