Class RxJavaErrorHandler

    • Constructor Detail

      • RxJavaErrorHandler

        public RxJavaErrorHandler()
    • Method Detail

      • handleError

        public void handleError(Throwable e)
        Receives all Exceptions 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.

        Parameters:
        e - the Exception
      • handleOnNextValueRendering

        @Beta
        public final 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. 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".

        Parameters:
        item - the last emitted item, that caused the exception wrapped in OnErrorThrowable.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

        @Beta
        protected String render(Object item)
                               throws 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 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 in OnErrorThrowable.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)