简单全局异常处理

代码

@ControllerAdvice  全局异常处理注解

@ExceptionHandler(Exception.class)  捕获异常并进行处理

@ControllerAdvice
public class AllExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Result doException(Exception exception) {
        return Result.fail(-999,"系统异常");
    }
}

 

posted @ 2022-09-11 10:55  Homnay  阅读(24)  评论(0)    收藏  举报