public class DefaultResponseErrorHandler extends ObjectSE implements ResponseErrorHandler
ResponseErrorHandler インターフェースの Spring のデフォルト実装。 このエラーハンドラーは、ClientHttpResponse のステータスコードをチェックします。4xx または 5xx シリーズのコードはエラーと見なされます。この動作は、hasError(HttpStatus) をオーバーライドすることで変更できます。不明なステータスコードは hasError(ClientHttpResponse) によって無視されます。
特定の例外型の詳細については、handleError(ClientHttpResponse) を参照してください。
RestTemplate.setErrorHandler(org.springframework.web.client.ResponseErrorHandler)| コンストラクターと説明 |
|---|
DefaultResponseErrorHandler() |
| 修飾子と型 | メソッドと説明 |
|---|---|
protected CharsetSE | getCharset(ClientHttpResponse response) レスポンスの文字セットを決定します(ステータス例外に含めるため)。 |
protected HttpStatus | getHttpStatusCode(ClientHttpResponse response) 使用すべきではありません。 5.0 現在、 handleError(ClientHttpResponse, HttpStatus) を推奨 |
protected byte[] | getResponseBody(ClientHttpResponse response) 指定されたレスポンスの本文を読み取ります(ステータス例外に含めるため)。 |
void | handleError(ClientHttpResponse response) 特定の解決済みステータスコードを使用して、特定のレスポンスのエラーを処理します。 |
protected void | handleError(ClientHttpResponse response, HttpStatus statusCode) 解決されたステータスコードに基づいてエラーを処理します。 |
boolean | hasError(ClientHttpResponse response) レスポンスステータスコードを持つ hasError(HttpStatus)(標準ステータス列挙値の場合)または hasError(int)(不明なステータスコードの場合)へのデリゲート。 |
protected boolean | hasError(HttpStatus statusCode)hasError(ClientHttpResponse) から呼び出されるテンプレートメソッド。 |
protected boolean | hasError(int unknownStatusCode)hasError(ClientHttpResponse) から呼び出されるテンプレートメソッド。 |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSEhandleErrorpublic boolean hasError(ClientHttpResponse response) throws IOExceptionSE
hasError(HttpStatus)(標準ステータス列挙値の場合)または hasError(int)(不明なステータスコードの場合)へのデリゲート。ResponseErrorHandler の hasError response - インスペクションするレスポンス true。それ以外の場合は false IOExceptionSE - I/O エラーの場合 ClientHttpResponse.getRawStatusCode(), hasError(HttpStatus), hasError(int)protected boolean hasError(HttpStatus statusCode)
hasError(ClientHttpResponse) から呼び出されるテンプレートメソッド。 デフォルトの実装は HttpStatus.isError() をチェックします。サブクラスでオーバーライドできます。
statusCode - 列挙値としての HTTP ステータスコード true。それ以外の場合は false HttpStatus.isError()protected boolean hasError(int unknownStatusCode)
hasError(ClientHttpResponse) から呼び出されるテンプレートメソッド。 デフォルトの実装では、指定されたステータスコードが CLIENT_ERROR または SERVER_ERROR かどうかを確認します。サブクラスでオーバーライドできます。
unknownStatusCode - 生の値としての HTTP ステータスコード true。それ以外の場合は false HttpStatus.Series.CLIENT_ERROR, HttpStatus.Series.SERVER_ERRORpublic void handleError(ClientHttpResponse response) throws IOExceptionSE
デフォルトの実装は以下をスローします:
HttpClientErrorException.BadRequest などのサブクラスの 1 つである場合は、HttpClientErrorException。HttpServerErrorException.InternalServerError などのサブクラスの 1 つである場合は、HttpServerErrorException。HttpStatus 列挙範囲にないエラーステータスコードの UnknownHttpStatusCodeException。ResponseErrorHandler の handleError response - エラーのあるレスポンス UnknownHttpStatusCodeException - 解決できないステータスコードの場合 IOExceptionSE - I/O エラーの場合 handleError(ClientHttpResponse, HttpStatus)protected void handleError(ClientHttpResponse response, HttpStatus statusCode) throws IOExceptionSE
デフォルトの実装は、4xx の範囲のエラーの場合は HttpClientErrorException.create(org.springframework.http.HttpStatus, java.lang.String, org.springframework.http.HttpHeaders, byte[], java.nio.charset.Charset) に委譲し、5xx の範囲のエラーの場合は HttpServerErrorException.create(org.springframework.http.HttpStatus, java.lang.String, org.springframework.http.HttpHeaders, byte[], java.nio.charset.Charset) に委譲するか、そうでなければ UnknownHttpStatusCodeException を発生させます。
IOExceptionSEHttpClientErrorException.create(org.springframework.http.HttpStatus, java.lang.String, org.springframework.http.HttpHeaders, byte[], java.nio.charset.Charset), HttpServerErrorException.create(org.springframework.http.HttpStatus, java.lang.String, org.springframework.http.HttpHeaders, byte[], java.nio.charset.Charset)@DeprecatedSE protected HttpStatus getHttpStatusCode(ClientHttpResponse response) throws IOExceptionSE
handleError(ClientHttpResponse, HttpStatus) に置き換えられました。response - インスペクションするレスポンス IOExceptionSE - I/O エラーの場合 UnknownHttpStatusCodeException - HttpStatus enum で表すことができない不明なステータスコードの場合 protected byte[] getResponseBody(ClientHttpResponse response)
response - インスペクションするレスポンス @Nullable protected CharsetSE getCharset(ClientHttpResponse response)
response - インスペクションするレスポンス null