Example usage for org.springframework.dao DuplicateKeyException getLocalizedMessage

List of usage examples for org.springframework.dao DuplicateKeyException getLocalizedMessage

Introduction

In this page you can find the example usage for org.springframework.dao DuplicateKeyException 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(DuplicateKeyException.class)
@ResponseStatus(value = HttpStatus.CONFLICT)
public @ResponseBody Map<String, Object> handleDuplicateKeyException(DuplicateKeyException ex)
        throws IOException {
    Map<String, Object> map = newHashMap();
    map.put("error", "Duplicate Key Exception");
    map.put("cause", ex.getLocalizedMessage());
    map.put("supported", ex.getMessage());
    return map;/*  ww w . ja v  a  2s . c o  m*/
}