クラス DefaultErrorWebExceptionHandler

java.lang.ObjectSE
org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler
org.springframework.boot.autoconfigure.web.reactive.error.DefaultErrorWebExceptionHandler
実装されたすべてのインターフェース:
InitializingBeanErrorWebExceptionHandlerWebExceptionHandler

public class DefaultErrorWebExceptionHandler extends AbstractErrorWebExceptionHandler
基本的なグローバル WebExceptionHandler、レンダリング ErrorAttributes

より具体的なエラーは、Spring WebFlux 抽象化(たとえば、@ExceptionHandler とアノテーションモデル)を使用するか、RouterFunction をチェーンに追加することによって処理できます。

この実装は、クライアントがそのメディア型を明示的にサポートしている場合、エラーを HTML ビューとしてレンダリングします。よく知られている規則を使用してエラービューを解決しようとします。status codestatus 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
  • コンストラクターの詳細

    • DefaultErrorWebExceptionHandler

      public DefaultErrorWebExceptionHandler(ErrorAttributes errorAttributes, WebProperties.Resources resources, ErrorProperties errorProperties, ApplicationContext applicationContext)
      新しい DefaultErrorWebExceptionHandler インスタンスを作成します。
      パラメーター:
      errorAttributes - エラー属性
      resources - リソース構成プロパティ
      errorProperties - エラー構成プロパティ
      applicationContext - 現在のアプリケーションコンテキスト
      導入:
      2.4.0
  • メソッドの詳細

    • getRoutingFunction

      protected RouterFunction<ServerResponse> getRoutingFunction(ErrorAttributes errorAttributes)
      クラスからコピーされた説明: AbstractErrorWebExceptionHandler
      JSON レスポンスまたは HTML ビューとしてエラーをルーティングおよび処理できる RouterFunction を作成します。

      返された RouterFunction が HandlerFunction にルーティングされない場合、元の例外はパイプラインに伝搬され、他の WebExceptionHandler によって処理できます。

      次で指定:
      クラス AbstractErrorWebExceptionHandlergetRoutingFunction 
      パラメーター:
      errorAttributes - エラー情報を抽出するために使用する ErrorAttributes インスタンス
      戻り値:
      エラーをルーティングして処理する RouterFunction
    • renderErrorView

      protected reactor.core.publisher.Mono<ServerResponse> renderErrorView(ServerRequest request)
      エラー情報を HTML ビューとしてレンダリングします。
      パラメーター:
      request - 現在のリクエスト
      戻り値:
      HTTP レスポンスの Publisher 
    • renderErrorResponse

      protected reactor.core.publisher.Mono<ServerResponse> renderErrorResponse(ServerRequest request)
      エラー情報を JSON ペイロードとしてレンダリングします。
      パラメーター:
      request - 現在のリクエスト
      戻り値:
      HTTP レスポンスの Publisher 
    • getErrorAttributeOptions

      protected ErrorAttributeOptions getErrorAttributeOptions(ServerRequest request, MediaType mediaType)
    • isIncludeStackTrace

      protected boolean isIncludeStackTrace(ServerRequest request, MediaType produces)
      stacktrace 属性を含めるかどうかを決定します。
      パラメーター:
      request - ソースリクエスト
      produces - 作成されたメディア型 (または MediaType.ALL)
      戻り値:
      stacktrace 属性を含める必要がある場合
    • isIncludeMessage

      protected boolean isIncludeMessage(ServerRequest request, MediaType produces)
      メッセージ属性を含めるかどうかを決定します。
      パラメーター:
      request - ソースリクエスト
      produces - 作成されたメディア型 (または MediaType.ALL)
      戻り値:
      メッセージ属性を含める必要がある場合
    • isIncludeBindingErrors

      protected boolean isIncludeBindingErrors(ServerRequest request, MediaType produces)
      エラー属性を含めるかどうかを決定します。
      パラメーター:
      request - ソースリクエスト
      produces - 作成されたメディア型 (または MediaType.ALL)
      戻り値:
      エラー属性を含める必要がある場合
    • getHttpStatus

      protected int getHttpStatus(MapSE<StringSE,ObjectSE> errorAttributes)
      エラーマップから HTTP エラーステータス情報を取得します。
      パラメーター:
      errorAttributes - 現在のエラー情報
      戻り値:
      エラー HTTP ステータス
    • acceptsTextHtml

      protected RequestPredicate acceptsTextHtml()
      現在のリクエストが "text/html" メディア型を明示的にサポートしているかどうかをチェックする述語。

      「全一致」メディア型はここでは考慮されません。

      戻り値:
      リクエストの述語