From c3e55d537e45e1e18b19557e918655aa04c59491 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 22 May 2020 07:49:01 +0100 Subject: [PATCH] DefaultResponseErrorHandler javadoc update Closes gh-25067 --- .../client/DefaultResponseErrorHandler.java | 40 +++++++++++++------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/client/DefaultResponseErrorHandler.java b/spring-web/src/main/java/org/springframework/web/client/DefaultResponseErrorHandler.java index 90c1b7a04a7b..ddd3ab2ae5c8 100644 --- a/spring-web/src/main/java/org/springframework/web/client/DefaultResponseErrorHandler.java +++ b/spring-web/src/main/java/org/springframework/web/client/DefaultResponseErrorHandler.java @@ -35,11 +35,14 @@ /** * Spring's default implementation of the {@link ResponseErrorHandler} interface. * - *

This error handler checks for the status code on the {@link ClientHttpResponse}: - * Any code with series {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR} - * or {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR} is considered to be - * an error; this behavior can be changed by overriding the {@link #hasError(HttpStatus)} - * method. Unknown status codes will be ignored by {@link #hasError(ClientHttpResponse)}. + *

This error handler checks for the status code on the + * {@link ClientHttpResponse}. Any code in the 4xx or 5xx series is considered + * to be an error. This behavior can be changed by overriding + * {@link #hasError(HttpStatus)}. Unknown status codes will be ignored by + * {@link #hasError(ClientHttpResponse)}. + * + *

See {@link #handleError(ClientHttpResponse)} for more details on specific + * exception types. * * @author Arjen Poutsma * @author Rossen Stoyanchev @@ -93,8 +96,18 @@ protected boolean hasError(int unknownStatusCode) { } /** - * Delegates to {@link #handleError(ClientHttpResponse, HttpStatus)} with the - * response status code. + * Handle the error in the given response with the given resolved status code. + *

The default implementation throws: + *

* @throws UnknownHttpStatusCodeException in case of an unresolvable status code * @see #handleError(ClientHttpResponse, HttpStatus) */ @@ -148,12 +161,13 @@ private String getErrorMessage( } /** - * Handle the error in the given response with the given resolved status code. - *

The default implementation throws an {@link HttpClientErrorException} - * if the status code is {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR - * CLIENT_ERROR}, an {@link HttpServerErrorException} if it is - * {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR SERVER_ERROR}, - * or an {@link UnknownHttpStatusCodeException} in other cases. + * Handle the error based on the resolved status code. + * + *

The default implementation delegates to + * {@link HttpClientErrorException#create} for errors in the 4xx range, to + * {@link HttpServerErrorException#create} for errors in the 5xx range, + * or otherwise raises {@link UnknownHttpStatusCodeException}. + * * @since 5.0 * @see HttpClientErrorException#create * @see HttpServerErrorException#create