廖井涛
2024-08-15 8b7d4b9527b9e196df4b9ac7cf113f06798f7941
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());
    }
    // 拦截:未登录异常