dahua xunxi exception bug

This commit is contained in:
caoqianming 2022-12-23 17:21:57 +08:00
parent 46a1fcf50a
commit 76b1fa0b82
2 changed files with 4 additions and 2 deletions

View File

@ -8,6 +8,7 @@ import uuid
import requests
from django.conf import settings
from rest_framework.exceptions import APIException, ParseError
from requests.exceptions import RequestException
from apps.third.errors import DH_REQUEST_ERROR
from apps.third.models import Tlog
@ -84,7 +85,7 @@ class DhClient:
return 'fail', err_detail
# self.handle_log(result='success', response=ret) # 成功的日志就不记录了
return 'success', ret['data'] if 'data' in ret else None
except Exception:
except RequestException:
self.handle_log(result='error', response=None)
if raise_exception:
raise APIException(**DH_REQUEST_ERROR)

View File

@ -6,6 +6,7 @@ import uuid
import requests
from django.conf import settings
from rest_framework.exceptions import APIException, ParseError
from requests.exceptions import RequestException
from apps.third.errors import XX_REQUEST_ERROR
from apps.third.models import Tlog
@ -72,7 +73,7 @@ class XxClient:
raise ParseError(**err_detail)
return 'fail', err_detail
return 'success', ret['data']
except Exception:
except RequestException:
self.handle_log(result='error', response=None)
if raise_exception:
raise APIException(**XX_REQUEST_ERROR)