guoyuji
2024-05-23 ef5a518c3e2c1fe41aa60f56ca31ddafa0cb1561
north-glass-erp/src/main/java/com/example/erp/exception/GlobalExceptionHandle.java
@@ -9,6 +9,8 @@
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Arrays;
@ControllerAdvice
public class GlobalExceptionHandle {
    /**
@@ -20,10 +22,11 @@
        return Result.error(se.getCode(),se.getMessage());
    }
    // 拦截:无权限异常
    @ExceptionHandler(NotPermissionException.class)
    @ResponseBody
    public Result handlerException(NotPermissionException e) {
        return Result.error(Constants.Code_401,"This user has no permission to access this resource");
        return Result.error(Constants.Code_401,e.getPermission());
    }
    // 拦截:未登录异常