Skip to content

Commit c3e55d5

Browse files
committed
DefaultResponseErrorHandler javadoc update
Closes gh-25067
1 parent d7a29bb commit c3e55d5

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

spring-web/src/main/java/org/springframework/web/client/DefaultResponseErrorHandler.java

+27-13
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@
3535
/**
3636
* Spring's default implementation of the {@link ResponseErrorHandler} interface.
3737
*
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.
4346
*
4447
* @author Arjen Poutsma
4548
* @author Rossen Stoyanchev
@@ -93,8 +96,18 @@ protected boolean hasError(int unknownStatusCode) {
9396
}
9497

9598
/**
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>
98111
* @throws UnknownHttpStatusCodeException in case of an unresolvable status code
99112
* @see #handleError(ClientHttpResponse, HttpStatus)
100113
*/
@@ -148,12 +161,13 @@ private String getErrorMessage(
148161
}
149162

150163
/**
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+
*
157171
* @since 5.0
158172
* @see HttpClientErrorException#create
159173
* @see HttpServerErrorException#create

0 commit comments

Comments
 (0)