Interface Hook.AfterError

  • All Known Implementing Classes:
    Hooks
    Enclosing class:
    Hook

    public static interface Hook.AfterError
    Specifies what happens if a request action throws an Exception.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static Hook.AfterError DEFAULT
      The default action is to rethrow the given error.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.net.http.HttpResponse<java.io.InputStream> afterError​(Hook.AfterErrorContext context, java.util.Optional<java.net.http.HttpResponse<java.io.InputStream>> response, java.util.Optional<java.lang.Exception> error)
      Either returns an HttpResponse or throws an Exception.
    • Field Detail

      • DEFAULT

        static final Hook.AfterError DEFAULT
        The default action is to rethrow the given error.
    • Method Detail

      • afterError

        java.net.http.HttpResponse<java.io.InputStream> afterError​(Hook.AfterErrorContext context,
                                                                   java.util.Optional<java.net.http.HttpResponse<java.io.InputStream>> response,
                                                                   java.util.Optional<java.lang.Exception> error)
                                                            throws java.lang.Exception
        Either returns an HttpResponse or throws an Exception. Must be passed either a response or an error (both can't be absent).
        Parameters:
        context - context for the error
        response - response information if available.
        error - the optional exception. If response present then the error is for-info only, it was the last error in the chain of AfterError hook calls leading to this one
        Returns:
        HTTP response if method decides that an exception is not to be thrown
        Throws:
        java.lang.Exception - if error to be propagated