dahua xunxi exception bug
This commit is contained in:
parent
46a1fcf50a
commit
76b1fa0b82
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue