Interface Stage.OnErrorResume

  • All Superinterfaces:
    Enclosing interface:

    public static interface Stage.OnErrorResume
    extends Stage
    A stage to handle errors from upstream. It builds a stream containing all the elements from upstream. Additionally, in the case of failure, rather than propagating the error downstream, it invokes the given function method emits the result as the final event of the stream, terminating the stream after that.

    By default, when a stream encounters an error that prevents it from emitting the expected item to its subscriber, the stream (publisher) invokes its subscriber's onError method, and then terminates without invoking any more of its subscriber's methods. This operator changes this behavior. If the current stream encounters an error, instead of invoking its subscriber's onError method, it will instead emit the return value of the passed function. This operator prevents errors from propagating and allows supplying fallback data should errors be encountered.

    Any RuntimeException thrown by the function must be propagated downstream as an error, replacing the exception that the function was handling.

    • Method Detail

      • getFunction

        java.util.function.Function<java.lang.Throwable,?> getFunction​()
        The error handler.
        the error handler.