From 1d4c0d4a4225f3b91c9a913490e7b480fd55cda0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E5=89=8D=E6=98=8E?= <909355014@qq.com> Date: Tue, 5 Jul 2022 12:14:54 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=A4401=EF=BC=8C404=E7=9A=84400=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E5=85=A8400=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/utils/exceptions.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/utils/exceptions.py b/apps/utils/exceptions.py index 9fe64739..da5a6bc7 100755 --- a/apps/utils/exceptions.py +++ b/apps/utils/exceptions.py @@ -41,9 +41,12 @@ def custom_exception_hander(exc, context): set_rollback() data['request_id'] = request_id - return Response(data, status=exc.status_code, headers=headers) + status = exc.status_code + if status not in [401, 404]: + status = 400 + return Response(data, status=status, headers=headers) args = (request_id, traceback.format_exc()) myLogger.error(f"{args[0]}-{args[1]}") return Response(data={'err_code': 'server_error', - 'err_detail': traceback.format_exc(), + 'err_detail': '', 'err_msg': '服务器错误', 'request_id': request_id}, status=500)