Example usage for org.springframework.web HttpMediaTypeNotSupportedException getLocalizedMessage

List of usage examples for org.springframework.web HttpMediaTypeNotSupportedException getLocalizedMessage

Introduction

In this page you can find the example usage for org.springframework.web HttpMediaTypeNotSupportedException getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:be.bittich.quote.controller.impl.DefaultExceptionHandler.java

@RequestMapping(produces = APPLICATION_JSON)
@ExceptionHandler(HttpMediaTypeNotSupportedException.class)
@ResponseStatus(value = HttpStatus.UNSUPPORTED_MEDIA_TYPE)
public @ResponseBody Map<String, Object> handleUnsupportedMediaTypeException(
        HttpMediaTypeNotSupportedException ex) throws IOException {
    Map<String, Object> map = newHashMap();
    map.put("error", "Unsupported Media Type");
    map.put("cause", ex.getLocalizedMessage());
    map.put("supported", ex.getSupportedMediaTypes());
    return map;/*from   w  w w  .j a v  a2 s.  c  o m*/
}