Class RxJavaErrorHandler
- java.lang.Object
-
- rx.plugins.RxJavaErrorHandler
-
public abstract class RxJavaErrorHandler extends java.lang.ObjectAbstract class for defining error handling logic in addition to the normalObserver.onError(Throwable)behavior.For example, all
Exceptions can be logged using this handler even ifObserver.onError(Throwable)is ignored or not provided when anObservableis subscribed to.This plugin is also responsible for augmenting rendering of
OnErrorThrowable.OnNextValue.See
RxJavaPluginsor the RxJava GitHub Wiki for information on configuring plugins: https://github.com/ReactiveX/RxJava/wiki/Plugins.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringERROR_IN_RENDERING_SUFFIX
-
Constructor Summary
Constructors Constructor Description RxJavaErrorHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidhandleError(java.lang.Throwable e)Deprecated.java.lang.StringhandleOnNextValueRendering(java.lang.Object item)Receives items causingOnErrorThrowable.OnNextValueand gives a chance to choose the String representation of the item in theOnNextValuestacktrace rendering.protected java.lang.Stringrender(java.lang.Object item)Override this method to provide rendering for specific types other than primitive types and null.
-
-
-
Field Detail
-
ERROR_IN_RENDERING_SUFFIX
protected static final java.lang.String ERROR_IN_RENDERING_SUFFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
handleError
@Deprecated public void handleError(java.lang.Throwable e)
Deprecated.Receives allExceptions from anObservablepassed 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
@Beta public final java.lang.String handleOnNextValueRendering(java.lang.Object item)
Receives items causingOnErrorThrowable.OnNextValueand gives a chance to choose the String representation of the item in theOnNextValuestacktrace rendering. Returnsnullif 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
Throwableis 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
Stringrepresentation 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
@Beta protected java.lang.String render(java.lang.Object item) throws java.lang.InterruptedException
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
Throwableis 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
Stringrepresentation of the item if one is known for its type, or null for default - Throws:
java.lang.InterruptedException- if the rendering thread is interrupted- Since:
- (if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
-
-