public abstract class RxJavaErrorHandler extends Object
Observer.onError(Throwable)
behavior.
For example, all Exception
s can be logged using this handler even if
Observer.onError(Throwable)
is ignored or not provided when an Observable
is subscribed to.
This plugin is also responsible for augmenting rendering of OnErrorThrowable.OnNextValue
.
See RxJavaPlugins
or the RxJava GitHub Wiki for information on configuring plugins: https://github.com/ReactiveX/RxJava/wiki/Plugins.
Modifier and Type | Field and Description |
---|---|
protected static String |
ERROR_IN_RENDERING_SUFFIX |
Constructor and Description |
---|
RxJavaErrorHandler() |
Modifier and Type | Method and Description |
---|---|
void |
handleError(Throwable e)
|
String |
handleOnNextValueRendering(Object item)
Receives items causing
OnErrorThrowable.OnNextValue and gives a chance to choose the String
representation of the item in the OnNextValue stacktrace rendering. |
protected String |
render(Object item)
Override this method to provide rendering for specific types other than primitive types and null.
|
protected static final String ERROR_IN_RENDERING_SUFFIX
public void handleError(Throwable e)
Exception
s from an Observable
passed to
Observer.onError(Throwable)
.
This should never throw an Exception
. Make sure to try/catch(Throwable
) all code
inside this method implementation.
e
- the Exception
@Experimental public final String handleOnNextValueRendering(Object item)
OnErrorThrowable.OnNextValue
and gives a chance to choose the String
representation of the item in the OnNextValue
stacktrace rendering. Returns null
if this
type of item is not managed and should use default rendering.
Note that primitive types are always rendered as their toString()
value.
If a Throwable
is caught when rendering, this will fallback to the item's classname suffixed by
".errorRendering".
item
- the last emitted item, that caused the exception wrapped in
OnErrorThrowable.OnNextValue
String
representation of the item if one is known for its type, or null for
default@Experimental protected String render(Object item) throws InterruptedException
For performance and overhead reasons, this should should limit to a safe production of a short
String
(as large renderings will bloat up the stacktrace). Prefer to try/catch(Throwable
)
all code inside this method implementation.
If a Throwable
is caught when rendering, this will fallback to the item's classname suffixed by
".errorRendering".
item
- the last emitted item, that caused the exception wrapped in
OnErrorThrowable.OnNextValue
String
representation of the item if one is known for its type, or null for
defaultInterruptedException
- if the rendering thread is interruptedCopyright © 2015. All Rights Reserved.