---
id: error-handling
title: Error Handling
---

Errors in Flipper plugins should be hidden from the user while providing actionable data to the plugin Developer.

## Android

To gracefully handle errors in Flipper, use the following classes:

* `FlipperResponder` - an instance is provided to the client plugin on every method call, which enables 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` - a custom `Runnable` that catches all exceptions, stopping them from crashing the application and reports them to Flipper. These error messages will show up in the DevTools console.

Executing the following block of code will always finish without error but may transfer any silent errors to the Flipper desktop app:

```java
new ErrorReportingRunnable(mConnection) {
  @Override
  public void runOrThrow() throws Exception {
    mightThrowException();
  }
}.run();
```

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.

## C++

To gracefully handle errors in Flipper, all transactions are performed inside of a 'Try' block, which catches all exceptions, stops them from crashing the application,  and reports them to the plugin Developer. This includes your own customs implementations of `FlipperPlugin::didConnect()` and `FlipperConnection::send()` and `::receive()`.

This means you can safely throw exceptions in your plugin code; the exception messages will be sent to the Flipper desktop app.

During plugin development the exception messages are surfaced in the Chrome dev console.

If your plugin performs asynchronous work in which exceptions are thrown, these exceptions will not be caught by the Flipper infrastructure. You should handle them appropriately.
