Commit d2b6f357 by fz

1.添加车钥匙异常处理

1 parent 24e6cb78
package com.glsx.smart.exception;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-16
*/
public class CarKeyException extends RuntimeException {
private Integer code;
private String message;
public CarKeyException() {}
public CarKeyException(ResultEnum resultEnum) {
this.code = resultEnum.getCode();
this.message = resultEnum.getMessage();
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
@Override
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public static CarKeyException create(int code, String message){
CarKeyException businessException = new CarKeyException();
businessException.code = code;
businessException.message = message;
return businessException;
}
public static CarKeyException create(ResultEnum resultEnum) {
return create(resultEnum.getCode(), resultEnum.getMessage());
}
}
...@@ -25,6 +25,12 @@ public class GlobalExceptionHandler { ...@@ -25,6 +25,12 @@ public class GlobalExceptionHandler {
return R.error(e.getMessage()); return R.error(e.getMessage());
} }
@ExceptionHandler({CarKeyException.class})
public R handleCarKeyException(CarKeyException e) {
log.error("车钥匙异常", e);
return R.error(e.getCode(),e.getMessage());
}
@ExceptionHandler({ServletRequestBindingException.class, MethodArgumentNotValidException.class, @ExceptionHandler({ServletRequestBindingException.class, MethodArgumentNotValidException.class,
BindException.class}) BindException.class})
public R handleBindException(Exception e) { public R handleBindException(Exception e) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!