exceptions.py 722 B

123456789101112131415161718192021
  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 = f'pdns response code: {response.status_code}, body: {response.text}' if response is not None else None
  11. return super().__init__(detail)
  12. class ConcurrencyException(APIException):
  13. status_code = status.HTTP_429_TOO_MANY_REQUESTS
  14. default_detail = 'Too many concurrent requests.'
  15. default_code = 'concurrency_conflict'