@RestControllerAdvice
public class BaseExceptionHandler {
@ExceptionHandler(value = Exception.class)
public Result exception(Exception e){
e.printStackTrace();
return new Result(false, StatusCode.ERROR,e.getMessage());
}
}
在需要抛异常的地方
throw new RuntimeException("权限不足!");