package com.water.watersys.components; import cn.dev33.satoken.exception.NotLoginException; import cn.dev33.satoken.util.SaResult; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; @RestControllerAdvice public class GlobalExceptionHandler { /** * 全局异常拦截,鉴权失败不会报错,会返回给前端报错原因 * @param e * @return */ @ExceptionHandler public SaResult handlerException(Exception e) { e.printStackTrace(); return SaResult.error(e.getMessage()); } @ExceptionHandler public SaResult notLoginException(NotLoginException e){ e.printStackTrace(); return SaResult.error(e.getMessage()); } }