1234567891011121314151617 |
- import json
- from json import JSONDecodeError
- from rest_framework.exceptions import APIException
- class PdnsException(APIException):
- def __init__(self, response=None, detail=None, status=None):
- self.status_code = status or response.status_code
- if detail:
- self.detail = detail
- else:
- try:
- self.detail = json.loads(response.text)['error']
- except (JSONDecodeError, KeyError):
- self.detail = response.text
|