exceptions.py 770 B

12345678910111213141516171819202122232425
  1. from rest_framework import status
  2. from rest_framework.exceptions import APIException
  3. class RequestEntityTooLarge(APIException):
  4. status_code = status.HTTP_413_REQUEST_ENTITY_TOO_LARGE
  5. default_detail = "Payload too large."
  6. default_code = "too_large"
  7. class PDNSException(APIException):
  8. def __init__(self, response=None):
  9. self.response = response
  10. detail = (
  11. f"pdns response code: {response.status_code}, body: {response.text}"
  12. if response is not None
  13. else None
  14. )
  15. return super().__init__(detail)
  16. class ConcurrencyException(APIException):
  17. status_code = status.HTTP_429_TOO_MANY_REQUESTS
  18. default_detail = "Too many concurrent requests."
  19. default_code = "concurrency_conflict"