Class UnsupportedMediaTypeStatusException

All Implemented Interfaces:
Serializable

public class UnsupportedMediaTypeStatusException extends ResponseStatusException
Exception for errors that fit response status 415 (unsupported media type).
Since:
5.0
Author:
Rossen Stoyanchev
See Also:
  • Constructor Details

    • UnsupportedMediaTypeStatusException

      public UnsupportedMediaTypeStatusException(@Nullable String reason)
      Constructor for when the specified Content-Type is invalid.
    • UnsupportedMediaTypeStatusException

      public UnsupportedMediaTypeStatusException(@Nullable MediaType contentType, List<MediaType> supportedTypes)
      Constructor for when the Content-Type can be parsed but is not supported.
    • UnsupportedMediaTypeStatusException

      public UnsupportedMediaTypeStatusException(@Nullable MediaType contentType, List<MediaType> supportedTypes, @Nullable ResolvableType bodyType)
      Constructor for when trying to encode from or decode to a specific Java type.
      Since:
      5.1
    • UnsupportedMediaTypeStatusException

      public UnsupportedMediaTypeStatusException(@Nullable MediaType contentType, List<MediaType> supportedTypes, @Nullable HttpMethod method)
      Constructor that provides the HTTP method.
      Since:
      5.3.6
    • UnsupportedMediaTypeStatusException

      public UnsupportedMediaTypeStatusException(@Nullable MediaType contentType, List<MediaType> supportedTypes, @Nullable ResolvableType bodyType, @Nullable HttpMethod method)
      Constructor for when trying to encode from or decode to a specific Java type.
      Since:
      5.3.6
  • Method Details

    • getContentType

      @Nullable public MediaType getContentType()
      Return the request Content-Type header if it was parsed successfully, or null otherwise.
    • getSupportedMediaTypes

      public List<MediaType> getSupportedMediaTypes()
      Return the list of supported content types in cases when the Content-Type header is parsed but not supported, or an empty list otherwise.
    • getBodyType

      @Nullable public ResolvableType getBodyType()
      Return the body type in the context of which this exception was generated.

      This is applicable when the exception was raised as a result trying to encode from or decode to a specific Java type.

      Returns:
      the body type, or null if not available
      Since:
      5.1
    • getResponseHeaders

      public HttpHeaders getResponseHeaders()
      Description copied from class: ResponseStatusException
      Return headers associated with the exception that should be added to the error response, e.g. "Allow", "Accept", etc.

      The default implementation in this class returns empty headers.

      Overrides:
      getResponseHeaders in class ResponseStatusException