public class DefaultResponseErrorHandler extends ObjectSE implements ResponseErrorHandler
ResponseErrorHandler インターフェースの Spring のデフォルト実装。 このエラーハンドラーは、ClientHttpResponse のステータスコードをチェックします。シリーズ HttpStatus.Series.CLIENT_ERROR または HttpStatus.Series.SERVER_ERROR のコードはすべてエラーと見なされます。この動作は、hasError(HttpStatus) メソッドをオーバーライドすることで変更できます。
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) レスポンスステータスコードを使用して handleError(ClientHttpResponse, HttpStatus) にデリゲートします。 |
protected void | handleError(ClientHttpResponse response, HttpStatus statusCode) 特定の解決済みステータスコードを使用して、特定のレスポンスのエラーを処理します。 |
boolean | hasError(ClientHttpResponse response) レスポンスステータスコードを使用して hasError(HttpStatus) にデリゲートします。 |
protected boolean | hasError(HttpStatus statusCode)hasError(ClientHttpResponse) から呼び出されるテンプレートメソッド。 |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSEhandleErrorpublic boolean hasError(ClientHttpResponse response) throws IOExceptionSE
hasError(HttpStatus) にデリゲートします。ResponseErrorHandler 内の hasError response - インスペクションするレスポンス true。それ以外の場合は false IOExceptionSE - I/O エラーの場合 protected boolean hasError(HttpStatus statusCode)
hasError(ClientHttpResponse) から呼び出されるテンプレートメソッド。 デフォルトの実装では、指定されたステータスコードが CLIENT_ERROR または SERVER_ERROR であるかどうかがチェックされます。サブクラスでオーバーライドできます。
statusCode - HTTP ステータスコード true。それ以外の場合は false public void handleError(ClientHttpResponse response) throws IOExceptionSE
handleError(ClientHttpResponse, HttpStatus) にデリゲートします。ResponseErrorHandler 内の handleError response - エラーのあるレスポンス IOExceptionSE - I/O エラーの場合 protected void handleError(ClientHttpResponse response, HttpStatus statusCode) throws IOExceptionSE
このデフォルトの実装は、レスポンスステータスコードが HttpStatus.Series.CLIENT_ERROR の場合は HttpClientErrorException をスローし、HttpStatus.Series.SERVER_ERROR の場合は HttpServerErrorException をスローし、それ以外の場合は RestClientException をスローします。
IOExceptionSE@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