use of org.springframework.web.bind.annotation.ExceptionHandler in project skeleton-commons by skeleton-software-community.
the class RestExceptionHandler method handleException.
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(Exception.class)
@ResponseBody
public ErrorReport handleException(Exception e) {
logger.error("exception thrown : " + e.getMessage(), e);
ErrorReport errorReport = new ErrorReport();
errorReport.setExceptionClassName(TechnicalError.class.getName());
errorReport.setMessage(ApplicationException.ERROR_UNKNOWN);
return errorReport;
}
use of org.springframework.web.bind.annotation.ExceptionHandler in project seldon-core by SeldonIO.
the class ExceptionControllerAdvice method handleUnauthorizedException.
@ExceptionHandler(SeldonAPIException.class)
public ResponseEntity<String> handleUnauthorizedException(SeldonAPIException exception) throws InvalidProtocolBufferException {
Status.Builder statusBuilder = Status.newBuilder();
statusBuilder.setCode(exception.getApiExceptionType().getId());
statusBuilder.setReason(exception.getApiExceptionType().getMessage());
statusBuilder.setInfo(exception.getInfo());
statusBuilder.setStatus(Status.StatusFlag.FAILURE);
Status status = statusBuilder.build();
String json;
json = ProtoBufUtils.toJson(status);
return new ResponseEntity<String>(json, HttpStatus.valueOf(exception.getApiExceptionType().getHttpCode()));
}
use of org.springframework.web.bind.annotation.ExceptionHandler 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);
}
use of org.springframework.web.bind.annotation.ExceptionHandler in project goci by EBISPOT.
the class ExceptionHandlerAdvice method handleResourceNotFound.
@ExceptionHandler(ResourceNotFoundException.class)
public ResponseEntity<ErrorResponse> handleResourceNotFound(ResourceNotFoundException ex, HttpServletRequest req) {
ErrorResponse error = ErrorResponse.basicResponse(HttpStatus.NOT_FOUND, ex, req, dateFormat);
log.error(error.toString());
return new ResponseEntity<>(error, HttpStatus.NOT_FOUND);
}
use of org.springframework.web.bind.annotation.ExceptionHandler in project pinpoint by naver.
the class ControllerExceptionHandler method defaultErrorHandler.
@ExceptionHandler(value = Exception.class)
public ModelAndView defaultErrorHandler(HttpServletRequest request, Exception exception) throws Exception {
Objects.requireNonNull(request, "request");
Objects.requireNonNull(exception, "exception");
InternalServerError.RequestInfo requestInfo = createRequestResource(request);
logger.warn("Failed to execute controller methods. message:{}, request:{}.", exception.getMessage(), requestInfo, exception);
ModelAndView mav = new ModelAndView();
InternalServerError error = createExceptionResource(requestInfo, exception);
mav.addObject("exception", error);
mav.setViewName(DEFAULT_ERROR_VIEW);
mav.setStatus(HttpStatus.INTERNAL_SERVER_ERROR);
return mav;
}
Aggregations