@Data
@AllArgsConstructor
@NoArgsConstructor
public class GuliException extends RuntimeException {
    
    private Integer code;
    
    private String msg;
}
# 统一异常类
```java
@ControllerAdvice
public class exceptionHandler {
    @ExceptionHandler(Exception.class)
    
    @ResponseBody
    public R error(Exception e){
        e.printStackTrace();
        return R.error().message("执行了全局异常处理");
    }
    
    @ExceptionHandler(ArithmeticException.class)
    
    @ResponseBody
    public R error(ArithmeticException e){
        e.printStackTrace();
        return R.error().message("执行了ArithmeticException异常处理");
    }
    
    @ExceptionHandler(GuliException.class)
    
    @ResponseBody
    public R error(GuliException e){
        e.printStackTrace();
        return R.error().code(e.getCode()).message(e.getMsg());
    }
}