Add local error handling in WebClient.retrieve

This commit introduces a way to customize the WebClientExceptions, as
thrown by WebClient.ResponseSpec.bodyTo[Mono|Flux]. The first
customization will override the defaults, additional customizations are
simply tried in order.

Issue: SPR-15724
This commit is contained in:
Arjen Poutsma
2017-07-06 15:55:10 +02:00
parent 2ea693bd83
commit 2f9bd6e075
4 changed files with 99 additions and 11 deletions

View File

@@ -465,6 +465,16 @@ public enum HttpStatus {
return Series.SERVER_ERROR.equals(series());
}
/**
* Whether this status code is in the HTTP series
* {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR} or
* {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR}.
* This is a shortcut for checking the value of {@link #series()}.
*/
public boolean isError() {
return is4xxClientError() || is5xxServerError();
}
/**
* Returns the HTTP status series of this status code.
* @see HttpStatus.Series