- Enclosing class:
RestClient
Error handler, must be a
ServiceRegistry
service.
Handles a response, and (possibly) returns an exception to be thrown.-
Method Summary
Modifier and TypeMethodDescriptionOptional
<? extends RuntimeException> handleError
(String requestUri, ClientRequestHeaders requestHeaders, ClientResponseTyped<?> typedResponse, Class<?> type) Handle a response.Optional
<? extends RuntimeException> handleError
(String requestUri, ClientRequestHeaders requestHeaders, HttpClientResponse response) Handle a response.default boolean
handles
(String requestUri, ClientRequestHeaders requestHeaders, Status status, ClientResponseHeaders headers) By default, we expect error handlers to handle exceptional responses.
-
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 URIrequestHeaders
- request headersstatus
- status to checkheaders
- 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 URIrequestHeaders
- request headersresponse
- 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 URIrequestHeaders
- request headerstypedResponse
- response we received from the servertype
- 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
-