Interface RestClient.ErrorHandler

Enclosing class:
RestClient

@Contract public static interface RestClient.ErrorHandler
Error handler, must be a ServiceRegistry service. Handles a response, and (possibly) returns an exception to be thrown.
  • Method Details

    • handles

      default boolean handles(String requestUri, ClientRequestHeaders requestHeaders, Status status, ClientResponseHeaders headers)
      By default, we expect error handlers to handle exceptional responses.
      Parameters:
      requestUri - requested URI
      requestHeaders - request headers
      status - status to check
      headers - header to check
      Returns:
      true in case this handler should be invoked
    • handleError

      Optional<? extends RuntimeException> handleError(String requestUri, ClientRequestHeaders requestHeaders, HttpClientResponse response)
      Handle a response.
      Parameters:
      requestUri - requested URI
      requestHeaders - request headers
      response - response we received from the server
      Returns:
      possible exception to throw, if empty, the invocation will be considered a success, even if the status denoted an error
    • handleError

      Optional<? extends RuntimeException> handleError(String requestUri, ClientRequestHeaders requestHeaders, ClientResponseTyped<?> typedResponse, Class<?> type)
      Handle a response.
      Parameters:
      requestUri - requested URI
      requestHeaders - request headers
      typedResponse - response we received from the server
      type - entity class (type of the typed response)
      Returns:
      possible exception to throw, if empty, the invocation will be considered a success, even if the status denoted an error