public class SystemException extends RuntimeException{ private Integer code; public Integer getCode() { return code; } public void setCode(Integer code) { this.code = code; } public SystemException(String message, Integer code) { super(message); this.code = code; } public SystemException(String message, Throwable cause, Integer code) { super(message, cause); this.code = code; } }
@RestControllerAdvice public class ProjectExceptionAdvice { @ExceptionHandler(Exception.class) public R doException(Exception e){ return R.err("出错了"); } }