Interface ErrorResponse.Interceptor

Enclosing interface:
ErrorResponse
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public static interface ErrorResponse.Interceptor
Callback to perform an action before an RFC-9457 ProblemDetail response is rendered.

Implementations that need the current request, for example to read request headers or parameters, can override handleError(ProblemDetail, ErrorResponse, HttpRequest).

Since:
6.2
Author:
Rossen Stoyanchev
  • Method Details

    • handleError

      void handleError(ProblemDetail detail, @Nullable ErrorResponse errorResponse)
      Handle the given ProblemDetail that's going to be rendered, and the ErrorResponse it originates from, if applicable.
      Parameters:
      detail - the ProblemDetail to be rendered
      errorResponse - the ErrorResponse, or null if there isn't one
    • handleError

      default void handleError(ProblemDetail detail, @Nullable ErrorResponse errorResponse, HttpRequest request)
      Variant of handleError(ProblemDetail, ErrorResponse) with access to the current request.

      This is the method invoked by the framework. By default, it delegates to handleError(ProblemDetail, ErrorResponse).

      Parameters:
      detail - the ProblemDetail to be rendered
      errorResponse - the ErrorResponse, or null if there isn't one
      request - the current HTTP request
      Since:
      7.1