Interface ErrorResponse

All Known Implementing Classes:
AsyncRequestTimeoutException, ErrorResponseException, HttpMediaTypeException, HttpMediaTypeNotAcceptableException, HttpMediaTypeNotSupportedException, HttpRequestMethodNotSupportedException, MethodArgumentNotValidException, MethodNotAllowedException, MissingMatrixVariableException, MissingPathVariableException, MissingRequestCookieException, MissingRequestHeaderException, MissingRequestValueException, MissingServletRequestParameterException, MissingServletRequestPartException, NoHandlerFoundException, NotAcceptableStatusException, ResponseStatusException, ServerErrorException, ServerWebInputException, ServletRequestBindingException, UnsatisfiedServletRequestParameterException, UnsupportedMediaTypeStatusException, WebExchangeBindException

public interface ErrorResponse
Representation of a complete RFC 7807 error response including status, headers, and an RFC 7808 formatted ProblemDetail body. Allows any exception to expose HTTP error response information.

ErrorResponseException is a default implementation of this interface and a convenient base class for other exceptions to use.

An @ExceptionHandler method can use org.springframework.http.ResponseEntity#of(ErrorResponse) to map an ErrorResponse to a ResponseEntity.

Since:
6.0
Author:
Rossen Stoyanchev
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Return the body for the response, formatted as an RFC 7807 ProblemDetail whose status should match the response status.
    default HttpHeaders
    Return headers to use for the response.
    int
    Return the HTTP status value for the response, potentially non-standard and not resolvable via HttpStatus.
    default HttpStatus
    Return the HTTP status to use for the response.
  • Method Details

    • getStatus

      default HttpStatus getStatus()
      Return the HTTP status to use for the response.
      Throws:
      IllegalArgumentException - for an unknown HTTP status code
    • getRawStatusCode

      int getRawStatusCode()
      Return the HTTP status value for the response, potentially non-standard and not resolvable via HttpStatus.
    • getHeaders

      default HttpHeaders getHeaders()
      Return headers to use for the response.
    • getBody

      ProblemDetail getBody()
      Return the body for the response, formatted as an RFC 7807 ProblemDetail whose status should match the response status.