exceptions.py 436 B

123456789101112131415
  1. from rest_framework.exceptions import APIException
  2. import json
  3. class PdnsException(APIException):
  4. def __init__(self, response=None, detail=None, status=None):
  5. self.status_code = status or response.status_code
  6. if detail:
  7. self.detail = detail
  8. else:
  9. try:
  10. self.detail = json.loads(response.text)['error']
  11. except:
  12. self.detail = response.text