public interface AsyncExceptionListener
It is implementation detail if exception listener is global per application or create new instance for every asynchronous
logic. Here is an example of using exception lister with looper thread. LooperThread
takes care to trigger
onAsyncException(Throwable)
.
class DemoLooper implements Looper, AsyncExceptionListener { private LooperThread thread; DemoLooper() { tread = new LooperThread(this); ... } void onAsyncException(Throwable throwable) { // handle loop iteration exception } }
If user code creates its own thread is recommended to invoke this listener like in sample code below.
public void run() { try { ... } catch (Throwable throwable) { listener.onAsyncException(throwable); } }
Modifier and Type | Method and Description |
---|---|
void |
onAsyncException(Throwable throwable)
Hook method executed when an asynchronous logic fails.
|
void onAsyncException(Throwable throwable)
throwable
- exception generated by an asynchronous logic.Copyright © 2018. All rights reserved.