use of org.springframework.web.bind.annotation.ExceptionHandler in project Saturn by vipshop.
the class SaturnJobConsoleExceptionHandlerController method handleSaturnJobConsoleHttpException.
@ExceptionHandler
public ResponseEntity<Object> handleSaturnJobConsoleHttpException(SaturnJobConsoleHttpException e) {
HttpHeaders httpHeaders = new HttpHeaders();
SaturnJobConsoleHttpException saturnJobConsoleHttpException = (SaturnJobConsoleHttpException) e;
int statusCode = saturnJobConsoleHttpException.getStatusCode();
if (statusCode == HttpStatus.CREATED.value()) {
return new ResponseEntity<>(httpHeaders, HttpStatus.CREATED);
}
return constructErrorResponse(e.getMessage(), HttpStatus.valueOf(statusCode));
}
use of org.springframework.web.bind.annotation.ExceptionHandler in project Saturn by vipshop.
the class RestApiExceptionHandlerController method handleSaturnJobConsoleHttpException.
@ExceptionHandler
public ResponseEntity<Object> handleSaturnJobConsoleHttpException(SaturnJobConsoleHttpException e) {
HttpHeaders httpHeaders = new HttpHeaders();
SaturnJobConsoleHttpException saturnJobConsoleHttpException = (SaturnJobConsoleHttpException) e;
int statusCode = saturnJobConsoleHttpException.getStatusCode();
if (statusCode == HttpStatus.CREATED.value()) {
return new ResponseEntity<>(httpHeaders, HttpStatus.CREATED);
}
return constructErrorResponse(e.getMessage(), HttpStatus.valueOf(statusCode));
}
use of org.springframework.web.bind.annotation.ExceptionHandler in project transporter by wang4ever.
the class BasicTransportController method writeException.
/**
* 输出异常信息
*
* @param t
* @return
*/
@ExceptionHandler(value = Throwable.class)
private Object writeException(Throwable t) {
JSONObject ret = new JSONObject();
if (t instanceof IllegalAccessException)
ret.put("code", "401");
else
ret.put("code", "500");
ret.put("data", StringUtils.split(ExceptionUtils.getRootCauseMessage(t), ":")[1]);
logger.error("Request error: {}", t);
return ret;
}
use of org.springframework.web.bind.annotation.ExceptionHandler in project ArachneCentralAPI by OHDSI.
the class ExceptionHandlingController method exceptionHandler.
@ExceptionHandler(UserNotFoundException.class)
public ResponseEntity<JsonResult> exceptionHandler(UserNotFoundException ex, HttpServletResponse response) throws IOException {
LOGGER.error(ex.getMessage(), ex);
JsonResult result = new JsonResult<>(VALIDATION_ERROR);
result.setErrorMessage(ex.getMessage());
result.getValidatorErrors().put(ex.getField(), ex.getMessage());
response.sendRedirect("/auth/login?message=email-not-confirmed");
return new ResponseEntity<>(result, HttpStatus.OK);
}
use of org.springframework.web.bind.annotation.ExceptionHandler in project ArachneCentralAPI by OHDSI.
the class ExceptionHandlingController method exceptionHandler.
@ExceptionHandler(NotExistException.class)
public ResponseEntity<JsonResult> exceptionHandler(NotExistException ex) {
LOGGER.error(ex.getMessage());
JsonResult result = new JsonResult<>(VALIDATION_ERROR);
result.setErrorMessage(ex.getMessage());
result.getValidatorErrors().put(ex.getEntity().getSimpleName(), ex.getMessage());
return new ResponseEntity<>(result, HttpStatus.OK);
}
Aggregations