From 37101cd1a785a85cdcd64e04a2d6f89ef6437c84 Mon Sep 17 00:00:00 2001 From: John Knox Date: Fri, 3 May 2019 10:26:10 -0700 Subject: [PATCH] Tidy up error handling page Summary: Some wording corrections, and added FlipperResponder section. Reviewed By: passy Differential Revision: D15200397 fbshipit-source-id: 2d52b1d7cb55b4cb8b0e15f00242201edf520f16 --- docs/extending/error-handling.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/extending/error-handling.md b/docs/extending/error-handling.md index eb7fefdeb..130ea6121 100644 --- a/docs/extending/error-handling.md +++ b/docs/extending/error-handling.md @@ -7,7 +7,11 @@ Errors in Flipper plugins should be hidden from the user while providing actiona ## Android -To gracefully handle errors in Flipper we provide the `ErrorReportingRunnable` class. This is a custom runnable which catches all exceptions, stopping them from crashing the application and reporting them to the plugin developer. +To gracefully handle errors in Flipper we provide the `ErrorReportingRunnable` and `FlipperResponder` classes. + +A `FlipperResponder` instance is provided to the client plugin on every method call, and allows for it to return results. When an error occurs during a Flipper method call that can't be handled, pass the error to the responder. This will let the desktop plugin handle it, and if it doesn't, the error will be displayed in the DevTools console. + +`ErrorReportingRunnable` is a custom `Runnable` which catches all exceptions, stopping them from crashing the application and reports them to Flipper. These error messages will show up in the DevTools console. ```java new ErrorReportingRunnable(mConnection) { @@ -18,7 +22,7 @@ new ErrorReportingRunnable(mConnection) { }.run(); ``` -Executing this block of code will always finish without error but may transfer any silences error to the Flipper desktop app. During plugin development these java stack traces are surfaced in the chrome dev console. In production the errors are instead sent to and a task is assigned so that you can quickly deploy a fix. +Executing this block of code will always finish without error but may transfer any silent errors to the Flipper desktop app. During plugin development these java stack traces are surfaced in the chrome dev console. Always use `ErrorReportingRunnable` for error handling instead of `try`/`catch` or even worse letting errors crash the app. With ErrorReportingRunnable you won't block anyone and you won't hide any stack traces.