クラス DefaultErrorWebExceptionHandler
java.lang.ObjectSE
org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler
org.springframework.boot.autoconfigure.web.reactive.error.DefaultErrorWebExceptionHandler
- 実装されたすべてのインターフェース:
InitializingBean
、ErrorWebExceptionHandler
、WebExceptionHandler
基本的なグローバル
WebExceptionHandler
、レンダリング ErrorAttributes
。 より具体的なエラーは、Spring WebFlux 抽象化(たとえば、@ExceptionHandler
とアノテーションモデル)を使用するか、RouterFunction
をチェーンに追加することによって処理できます。
この実装は、クライアントがそのメディア型を明示的にサポートしている場合、エラーを HTML ビューとしてレンダリングします。よく知られている規則を使用してエラービューを解決しようとします。status code
と status series
を使用して、'/error'
でテンプレートと静的アセットを検索します。
例: HTTP 404
は(特定の順序で)検索します:
'/<templates>/error/404.<ext>'
'/<static>/error/404.html'
'/<templates>/error/4xx.<ext>'
'/<static>/error/4xx.html'
'/<templates>/error/error'
'/<static>/error/error.html'
何も見つからない場合、デフォルトの「ホワイトラベルエラー」HTML ビューがレンダリングされます。
クライアントが HTML をサポートしていない場合、エラー情報は JSON ペイロードとしてレンダリングされます。
- 導入:
- 2.0.0
- 作成者:
- Brian Clozel, Scott Frederick, Moritz Halbritter
コンストラクターのサマリー
コンストラクターコンストラクター説明DefaultErrorWebExceptionHandler
(ErrorAttributes errorAttributes, WebProperties.Resources resources, ErrorProperties errorProperties, ApplicationContext applicationContext) 新しいDefaultErrorWebExceptionHandler
インスタンスを作成します。方法の概要
修飾子と型メソッド説明protected RequestPredicate
現在のリクエストが"text/html"
メディア型を明示的にサポートしているかどうかをチェックする述語。protected ErrorAttributeOptions
getErrorAttributeOptions
(ServerRequest request, MediaType mediaType) protected int
getHttpStatus
(MapSE<StringSE, ObjectSE> errorAttributes) エラーマップから HTTP エラーステータス情報を取得します。protected RouterFunction<ServerResponse>
getRoutingFunction
(ErrorAttributes errorAttributes) JSON レスポンスまたは HTML ビューとしてエラーをルーティングおよび処理できるRouterFunction
を作成します。protected boolean
isIncludeBindingErrors
(ServerRequest request, MediaType produces) エラー属性を含めるかどうかを決定します。protected boolean
isIncludeMessage
(ServerRequest request, MediaType produces) メッセージ属性を含めるかどうかを決定します。protected boolean
isIncludePath
(ServerRequest request, MediaType produces) パス属性を含めるかどうかを決定します。protected boolean
isIncludeStackTrace
(ServerRequest request, MediaType produces) stacktrace 属性を含めるかどうかを決定します。protected reactor.core.publisher.Mono<ServerResponse>
renderErrorResponse
(ServerRequest request) エラー情報を JSON ペイロードとしてレンダリングします。protected reactor.core.publisher.Mono<ServerResponse>
renderErrorView
(ServerRequest request) エラー情報を HTML ビューとしてレンダリングします。クラス org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler から継承されたメソッド
afterPropertiesSet, getError, getErrorAttributes, handle, isBindingErrorsEnabled, isMessageEnabled, isPathEnabled, isTraceEnabled, logError, renderDefaultErrorView, renderErrorView, setMessageReaders, setMessageWriters, setViewResolvers
コンストラクターの詳細
DefaultErrorWebExceptionHandler
public DefaultErrorWebExceptionHandler(ErrorAttributes errorAttributes, WebProperties.Resources resources, ErrorProperties errorProperties, ApplicationContext applicationContext) 新しいDefaultErrorWebExceptionHandler
インスタンスを作成します。- パラメーター:
errorAttributes
- エラー属性resources
- リソース構成プロパティerrorProperties
- エラー構成プロパティapplicationContext
- 現在のアプリケーションコンテキスト- 導入:
- 2.4.0
メソッドの詳細
getRoutingFunction
クラスからコピーされた説明:AbstractErrorWebExceptionHandler
JSON レスポンスまたは HTML ビューとしてエラーをルーティングおよび処理できるRouterFunction
を作成します。返された
RouterFunction
がHandlerFunction
にルーティングされない場合、元の例外はパイプラインに伝搬され、他のWebExceptionHandler
によって処理できます。- 次で指定:
- クラス
AbstractErrorWebExceptionHandler
のgetRoutingFunction
- パラメーター:
errorAttributes
- エラー情報を抽出するために使用するErrorAttributes
インスタンス- 戻り値:
- エラーをルーティングして処理する
RouterFunction
renderErrorView
エラー情報を HTML ビューとしてレンダリングします。- パラメーター:
request
- 現在のリクエスト- 戻り値:
- HTTP レスポンスの
Publisher
renderErrorResponse
エラー情報を JSON ペイロードとしてレンダリングします。- パラメーター:
request
- 現在のリクエスト- 戻り値:
- HTTP レスポンスの
Publisher
getErrorAttributeOptions
protected ErrorAttributeOptions getErrorAttributeOptions(ServerRequest request, MediaType mediaType) isIncludeStackTrace
stacktrace 属性を含めるかどうかを決定します。- パラメーター:
request
- ソースリクエストproduces
- 作成されたメディア型 (またはMediaType.ALL
)- 戻り値:
- stacktrace 属性を含める必要がある場合
isIncludeMessage
メッセージ属性を含めるかどうかを決定します。- パラメーター:
request
- ソースリクエストproduces
- 作成されたメディア型 (またはMediaType.ALL
)- 戻り値:
- メッセージ属性を含める必要がある場合
isIncludeBindingErrors
エラー属性を含めるかどうかを決定します。- パラメーター:
request
- ソースリクエストproduces
- 作成されたメディア型 (またはMediaType.ALL
)- 戻り値:
- エラー属性を含める必要がある場合
isIncludePath
パス属性を含めるかどうかを決定します。- パラメーター:
request
- ソースリクエストproduces
- 作成されたメディア型 (またはMediaType.ALL
)- 戻り値:
- パス属性を含めるかどうか
- 導入:
- 3.3.0
getHttpStatus
エラーマップから HTTP エラーステータス情報を取得します。- パラメーター:
errorAttributes
- 現在のエラー情報- 戻り値:
- エラー HTTP ステータス
acceptsTextHtml
現在のリクエストが"text/html"
メディア型を明示的にサポートしているかどうかをチェックする述語。「全一致」メディア型はここでは考慮されません。
- 戻り値:
- リクエストの述語