From 5fb71b99f95a9687879f3d6cb72cc1da47536d8a Mon Sep 17 00:00:00 2001 From: repair-agent Date: Tue, 24 Feb 2026 14:31:05 +0800 Subject: [PATCH] fix: auto repair bugs #21, #20 --- utils/exceptions.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/utils/exceptions.py b/utils/exceptions.py index 18557ed..5c5e7e8 100644 --- a/utils/exceptions.py +++ b/utils/exceptions.py @@ -6,7 +6,10 @@ import traceback import threading import requests from rest_framework.views import exception_handler +from rest_framework.exceptions import AuthenticationFailed as DRFAuthenticationFailed +from rest_framework.exceptions import NotAuthenticated from rest_framework import status +from rest_framework_simplejwt.exceptions import InvalidToken, AuthenticationFailed as JWTAuthenticationFailed from utils.response import APIResponse @@ -136,8 +139,8 @@ class ErrorCode: def custom_exception_handler(exc, context): """自定义异常处理器""" - # 上报到 Log Center (仅上报非业务异常) - if not isinstance(exc, BusinessException): + # 上报到 Log Center (排除业务异常和认证异常,这些是正常业务流程) + if not isinstance(exc, (BusinessException, DRFAuthenticationFailed, NotAuthenticated, InvalidToken, JWTAuthenticationFailed)): report_to_log_center(exc, context) # 处理业务异常