|
35 | 35 | /**
|
36 | 36 | * Spring's default implementation of the {@link ResponseErrorHandler} interface.
|
37 | 37 | *
|
38 |
| - * <p>This error handler checks for the status code on the {@link ClientHttpResponse}: |
39 |
| - * Any code with series {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR} |
40 |
| - * or {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR} is considered to be |
41 |
| - * an error; this behavior can be changed by overriding the {@link #hasError(HttpStatus)} |
42 |
| - * method. Unknown status codes will be ignored by {@link #hasError(ClientHttpResponse)}. |
| 38 | + * <p>This error handler checks for the status code on the |
| 39 | + * {@link ClientHttpResponse}. Any code in the 4xx or 5xx series is considered |
| 40 | + * to be an error. This behavior can be changed by overriding |
| 41 | + * {@link #hasError(HttpStatus)}. Unknown status codes will be ignored by |
| 42 | + * {@link #hasError(ClientHttpResponse)}. |
| 43 | + * |
| 44 | + * <p>See {@link #handleError(ClientHttpResponse)} for more details on specific |
| 45 | + * exception types. |
43 | 46 | *
|
44 | 47 | * @author Arjen Poutsma
|
45 | 48 | * @author Rossen Stoyanchev
|
@@ -93,8 +96,18 @@ protected boolean hasError(int unknownStatusCode) {
|
93 | 96 | }
|
94 | 97 |
|
95 | 98 | /**
|
96 |
| - * Delegates to {@link #handleError(ClientHttpResponse, HttpStatus)} with the |
97 |
| - * response status code. |
| 99 | + * Handle the error in the given response with the given resolved status code. |
| 100 | + * <p>The default implementation throws: |
| 101 | + * <ul> |
| 102 | + * <li>{@link HttpClientErrorException} if the status code is in the 4xx |
| 103 | + * series, or one of its sub-classes such as |
| 104 | + * {@link HttpClientErrorException.BadRequest} and others. |
| 105 | + * <li>{@link HttpServerErrorException} if the status code is in the 5xx |
| 106 | + * series, or one of its sub-classes such as |
| 107 | + * {@link HttpServerErrorException.InternalServerError} and others. |
| 108 | + * <li>{@link UnknownHttpStatusCodeException} for error status codes not in the |
| 109 | + * {@link HttpStatus} enum range. |
| 110 | + * </ul> |
98 | 111 | * @throws UnknownHttpStatusCodeException in case of an unresolvable status code
|
99 | 112 | * @see #handleError(ClientHttpResponse, HttpStatus)
|
100 | 113 | */
|
@@ -148,12 +161,13 @@ private String getErrorMessage(
|
148 | 161 | }
|
149 | 162 |
|
150 | 163 | /**
|
151 |
| - * Handle the error in the given response with the given resolved status code. |
152 |
| - * <p>The default implementation throws an {@link HttpClientErrorException} |
153 |
| - * if the status code is {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR |
154 |
| - * CLIENT_ERROR}, an {@link HttpServerErrorException} if it is |
155 |
| - * {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR SERVER_ERROR}, |
156 |
| - * or an {@link UnknownHttpStatusCodeException} in other cases. |
| 164 | + * Handle the error based on the resolved status code. |
| 165 | + * |
| 166 | + * <p>The default implementation delegates to |
| 167 | + * {@link HttpClientErrorException#create} for errors in the 4xx range, to |
| 168 | + * {@link HttpServerErrorException#create} for errors in the 5xx range, |
| 169 | + * or otherwise raises {@link UnknownHttpStatusCodeException}. |
| 170 | + * |
157 | 171 | * @since 5.0
|
158 | 172 | * @see HttpClientErrorException#create
|
159 | 173 | * @see HttpServerErrorException#create
|
|
0 commit comments