Search in sources :

Example 1 with RestError

use of org.jumpmind.symmetric.web.rest.model.RestError in project symmetric-ds by JumpMind.

the class RestService method handleError.

@ExceptionHandler(Exception.class)
@ResponseBody
public RestError handleError(Exception ex, HttpServletRequest req) {
    int httpErrorCode = 500;
    Annotation annotation = ex.getClass().getAnnotation(ResponseStatus.class);
    if (annotation != null) {
        httpErrorCode = ((ResponseStatus) annotation).value().value();
    }
    return new RestError(ex, httpErrorCode);
}
Also used : ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RestError(org.jumpmind.symmetric.web.rest.model.RestError) Annotation(java.lang.annotation.Annotation) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

Annotation (java.lang.annotation.Annotation)1 RestError (org.jumpmind.symmetric.web.rest.model.RestError)1 ExceptionHandler (org.springframework.web.bind.annotation.ExceptionHandler)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1