From 98784826541af5b08f7f88fe524c527782c7d7f2 Mon Sep 17 00:00:00 2001 From: insistence <3055204202@qq.com> Date: Wed, 10 Jul 2024 21:00:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=85=A8=E5=B1=80?= =?UTF-8?q?=E5=A4=84=E7=90=86=E8=87=AA=E5=AE=9A=E4=B9=89=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-fastapi-backend/exceptions/handle.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ruoyi-fastapi-backend/exceptions/handle.py b/ruoyi-fastapi-backend/exceptions/handle.py index b4ad02b..2b18687 100644 --- a/ruoyi-fastapi-backend/exceptions/handle.py +++ b/ruoyi-fastapi-backend/exceptions/handle.py @@ -1,7 +1,7 @@ from fastapi import FastAPI, Request from fastapi.exceptions import HTTPException from pydantic_validation_decorator import FieldValidationError -from exceptions.exception import AuthException, PermissionException, ServiceException, ModelValidatorException +from exceptions.exception import AuthException, LoginException, PermissionException, ServiceException, ModelValidatorException from utils.log_util import logger from utils.response_util import ResponseUtil, JSONResponse, jsonable_encoder @@ -15,6 +15,11 @@ def handle_exception(app: FastAPI): async def auth_exception_handler(request: Request, exc: AuthException): return ResponseUtil.unauthorized(data=exc.data, msg=exc.message) + # 自定义登录检验异常 + @app.exception_handler(LoginException) + async def login_exception_handler(request: Request, exc: LoginException): + return ResponseUtil.failure(data=exc.data, msg=exc.message) + # 自定义权限检验异常 @app.exception_handler(PermissionException) async def permission_exception_handler(request: Request, exc: PermissionException):