org.springframework.web.reactive.function

## Class UnsupportedMediaTypeException

- java.lang.Object
- - java.lang.Throwable
  - - java.lang.Exception
    - - java.lang.RuntimeException
      - - org.springframework.core.NestedRuntimeException
        - - org.springframework.web.reactive.function.UnsupportedMediaTypeException

All Implemented Interfaces:
  Serializable

    public class UnsupportedMediaTypeException
    extends org.springframework.core.NestedRuntimeException

Exception thrown to indicate that a `Content-Type` is not supported.

Since:
  5.0
Author:
  Arjen Poutsma
See Also:
  Serialized Form

### Constructor Summary

Constructors
Constructor and Description
`UnsupportedMediaTypeException(org.springframework.http.MediaType contentType, List<org.springframework.http.MediaType> supportedTypes)` Constructor for when the Content-Type can be parsed but is not supported.
`UnsupportedMediaTypeException(org.springframework.http.MediaType contentType, List<org.springframework.http.MediaType> supportedTypes, org.springframework.core.ResolvableType bodyType)` Constructor for when trying to encode from or decode to a specific Java type.
`UnsupportedMediaTypeException(String reason)` Constructor for when the specified Content-Type is invalid.

### Method Summary

All Methods Instance Methods Concrete Methods
`org.springframework.core.ResolvableType` `getBodyType()` Return the body type in the context of which this exception was generated.
`org.springframework.http.MediaType` `getContentType()` Return the request Content-Type header if it was parsed successfully, or `null` otherwise.
`List<org.springframework.http.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.

### Methods inherited from class org.springframework.core.NestedRuntimeException

`contains, getMessage, getMostSpecificCause, getRootCause`

### Methods inherited from class java.lang.Throwable

`addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### UnsupportedMediaTypeException

    public UnsupportedMediaTypeException(String reason)

Constructor for when the specified Content-Type is invalid.

#### UnsupportedMediaTypeException

    public UnsupportedMediaTypeException(@Nullable
                                         org.springframework.http.MediaType contentType,
                                         List<org.springframework.http.MediaType> supportedTypes)

Constructor for when the Content-Type can be parsed but is not supported.

#### UnsupportedMediaTypeException

    public UnsupportedMediaTypeException(@Nullable
                                         org.springframework.http.MediaType contentType,
                                         List<org.springframework.http.MediaType> supportedTypes,
                                         @Nullable
                                         org.springframework.core.ResolvableType bodyType)

Constructor for when trying to encode from or decode to a specific Java type.

Since:
  5.1

### Method Detail

#### getContentType

    @Nullable
    public org.springframework.http.MediaType getContentType()

Return the request Content-Type header if it was parsed successfully, or `null` otherwise.

#### getSupportedMediaTypes

    public List<org.springframework.http.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 org.springframework.core.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