Example usage for org.springframework.orm ObjectRetrievalFailureException getRootCause

List of usage examples for org.springframework.orm ObjectRetrievalFailureException getRootCause

Introduction

In this page you can find the example usage for org.springframework.orm ObjectRetrievalFailureException getRootCause.

Prototype

@Nullable
public Throwable getRootCause() 

Source Link

Document

Retrieve the innermost cause of this exception, if any.

Usage

From source file:net.jkratz.igdb.controller.advice.ErrorController.java

@RequestMapping(produces = "application/json")
@ExceptionHandler(ObjectRetrievalFailureException.class)
@ResponseStatus(value = HttpStatus.NOT_FOUND)
public @ResponseBody Map<String, Object> handleObjectRetrievalFailureException(
        ObjectRetrievalFailureException ex) throws IOException {
    logger.error("Object not found", ex);
    Map<String, Object> map = Maps.newHashMap();
    map.put("error", "Entity Not Found");
    map.put("message", ex.getMessage());
    if (ex.getRootCause() != null) {
        map.put("cause", ex.getRootCause().getMessage());
    }//from  ww  w .  j  a v a 2  s .co m
    return map;
}