fix: auto repair bugs #21, #20
All checks were successful
Build and Deploy Backend / build-and-deploy (push) Successful in 6m44s
All checks were successful
Build and Deploy Backend / build-and-deploy (push) Successful in 6m44s
This commit is contained in:
parent
c96bef3515
commit
5fb71b99f9
@ -6,7 +6,10 @@ import traceback
|
|||||||
import threading
|
import threading
|
||||||
import requests
|
import requests
|
||||||
from rest_framework.views import exception_handler
|
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 import status
|
||||||
|
from rest_framework_simplejwt.exceptions import InvalidToken, AuthenticationFailed as JWTAuthenticationFailed
|
||||||
from utils.response import APIResponse
|
from utils.response import APIResponse
|
||||||
|
|
||||||
|
|
||||||
@ -136,8 +139,8 @@ class ErrorCode:
|
|||||||
|
|
||||||
def custom_exception_handler(exc, context):
|
def custom_exception_handler(exc, context):
|
||||||
"""自定义异常处理器"""
|
"""自定义异常处理器"""
|
||||||
# 上报到 Log Center (仅上报非业务异常)
|
# 上报到 Log Center (排除业务异常和认证异常,这些是正常业务流程)
|
||||||
if not isinstance(exc, BusinessException):
|
if not isinstance(exc, (BusinessException, DRFAuthenticationFailed, NotAuthenticated, InvalidToken, JWTAuthenticationFailed)):
|
||||||
report_to_log_center(exc, context)
|
report_to_log_center(exc, context)
|
||||||
|
|
||||||
# 处理业务异常
|
# 处理业务异常
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user