use of org.springframework.web.bind.annotation.ExceptionHandler in project alien4cloud by alien4cloud.
the class RestTechnicalExceptionHandler method paaSDeploymentErrorHandler.
@ExceptionHandler(value = PaaSDeploymentException.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseBody
public RestResponse<Void> paaSDeploymentErrorHandler(PaaSDeploymentException e) {
log.warn("Error in PaaS Deployment", e);
RestErrorCode errorCode = RestErrorCode.APPLICATION_DEPLOYMENT_ERROR;
if (e.getPassErrorCode() != null) {
errorCode = e.getPassErrorCode();
}
return RestResponseBuilder.<Void>builder().error(RestErrorBuilder.builder(errorCode).message("Application cannot be deployed " + e.getMessage()).build()).build();
}
use of org.springframework.web.bind.annotation.ExceptionHandler in project wechat by dllwh.
the class GlobalExceptionHandler method requestTypeMismatch.
/**
* 400 - Bad Request
*/
@ResponseBody
@ExceptionHandler(TypeMismatchException.class)
public AjaxJson requestTypeMismatch(TypeMismatchException ex) {
AjaxJson result = new AjaxJson();
if (logger.isDebugEnabled()) {
logger.error("TypeMismatchException", ex);
}
result.setSuccess(false);
result.setMsg(ex.getMessage());
result.setResultCode(400);
return result;
}
use of org.springframework.web.bind.annotation.ExceptionHandler in project wechat by dllwh.
the class GlobalExceptionHandler method handleMethodArgumentNotValidException.
/**
* 400 - Bad Request
*/
@ResponseBody
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(MethodArgumentNotValidException.class)
public AjaxJson handleMethodArgumentNotValidException(final MethodArgumentNotValidException e) {
AjaxJson result = new AjaxJson();
if (logger.isDebugEnabled()) {
logger.error("MethodArgumentNotValidException", e);
}
result.setSuccess(false);
result.setMsg(e.getMessage());
result.setResultCode(400);
return result;
}
use of org.springframework.web.bind.annotation.ExceptionHandler in project wechat by dllwh.
the class GlobalExceptionHandler method nullPointerExceptionHandler.
/**
* @方法:空指针异常
* @创建人:独泪了无痕
* @param ex
*/
@ResponseBody
@ExceptionHandler(NullPointerException.class)
public AjaxJson nullPointerExceptionHandler(NullPointerException ex) {
AjaxJson ajaxJson = new AjaxJson();
if (logger.isDebugEnabled()) {
logger.error("空指针异常:", ex);
}
ajaxJson.setSuccess(false);
ajaxJson.setResultCode(500);
ajaxJson.setMsg(NullPointerException.class.getName());
return ajaxJson;
}
use of org.springframework.web.bind.annotation.ExceptionHandler in project wechat by dllwh.
the class GlobalExceptionHandler method httpMessageNotWritableException.
/**
* 500 - Internal Server Error
*/
@ResponseBody
@ExceptionHandler(HttpMessageNotWritableException.class)
public AjaxJson httpMessageNotWritableException(HttpMessageNotWritableException e) {
AjaxJson result = new AjaxJson();
if (logger.isDebugEnabled()) {
logger.error(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase(), e);
}
result.setSuccess(false);
result.setMsg(e.getMessage());
result.setResultCode(500);
return result;
}
Aggregations