Class RxJavaErrorHandler
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.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Deprecated.final String
Receives items causingOnErrorThrowable.OnNextValue
and gives a chance to choose the String representation of the item in theOnNextValue
stacktrace rendering.protected String
Override this method to provide rendering for specific types other than primitive types and null.
-
Field Details
-
ERROR_IN_RENDERING_SUFFIX
- See Also:
-
-
Constructor Details
-
RxJavaErrorHandler
public RxJavaErrorHandler()
-
-
Method Details
-
handleError
Deprecated.Receives allException
s from anObservable
passed toObserver.onError(Throwable)
.This should never throw an
Exception
. Make sure to try/catch(Throwable
) all code inside this method implementation.- Parameters:
e
- theException
-
handleOnNextValueRendering
Receives items causingOnErrorThrowable.OnNextValue
and gives a chance to choose the String representation of the item in theOnNextValue
stacktrace rendering. Returnsnull
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 byERROR_IN_RENDERING_SUFFIX
.- Parameters:
item
- the last emitted item, that caused the exception wrapped inOnErrorThrowable.OnNextValue
- Returns:
- a short
String
representation of the item if one is known for its type, or null for default - Since:
- (if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
-
render
Override this method to provide rendering for specific types other than primitive types and null.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".- Parameters:
item
- the last emitted item, that caused the exception wrapped inOnErrorThrowable.OnNextValue
- Returns:
- a short
String
representation of the item if one is known for its type, or null for default - Throws:
InterruptedException
- if the rendering thread is interrupted- Since:
- (if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
-