Search in sources :

Example 6 with RestError

use of org.entando.entando.web.common.model.RestError in project entando-core by entando.

the class RestExceptionHandler method processRuntimeExceptionException.

@ExceptionHandler(value = RuntimeException.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseBody
public RestResponse processRuntimeExceptionException(RuntimeException ex) {
    logger.debug("Handling {} error", ex.getClass().getSimpleName());
    RestResponse response = new RestResponse();
    RestError error = new RestError(RestErrorCodes.INTERNAL_ERROR, this.resolveLocalizedErrorMessage("GENERIC_ERROR", new Object[] { ex.getMessage() }));
    List<RestError> errors = new ArrayList<>();
    errors.add(error);
    response.setErrors(errors);
    ex.printStackTrace();
    return response;
}
Also used : RestResponse(org.entando.entando.web.common.model.RestResponse) RestError(org.entando.entando.web.common.model.RestError) ArrayList(java.util.ArrayList) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ArrayList (java.util.ArrayList)6 RestError (org.entando.entando.web.common.model.RestError)6 RestResponse (org.entando.entando.web.common.model.RestResponse)4 ExceptionHandler (org.springframework.web.bind.annotation.ExceptionHandler)4 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)4 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)4 BindingResult (org.springframework.validation.BindingResult)1 FieldError (org.springframework.validation.FieldError)1 ObjectError (org.springframework.validation.ObjectError)1