You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.3 KiB

  1. from rest_framework import status
  2. from rest_framework.exceptions import APIException, PermissionDenied, ValidationError
  3. class FileParseException(APIException):
  4. status_code = status.HTTP_400_BAD_REQUEST
  5. default_detail = 'Invalid file format, line {}: {}'
  6. default_code = 'invalid'
  7. def __init__(self, line_num, line, code=None):
  8. detail = self.default_detail.format(line_num, line)
  9. super().__init__(detail, code)
  10. class AutoLabelingException(APIException):
  11. status_code = status.HTTP_400_BAD_REQUEST
  12. default_detail = 'Auto labeling not allowed for the document with labels.'
  13. class AutoLabeliingPermissionDenied(PermissionDenied):
  14. default_detail = 'You do not have permission to perform auto labeling.' \
  15. 'Please ask the project administrators to add you.'
  16. class URLConnectionError(ValidationError):
  17. default_detail = 'Failed to establish a connection. Please check the URL or network.'
  18. class AWSTokenError(ValidationError):
  19. default_detail = 'The security token included in the request is invalid.'
  20. class SampleDataException(ValidationError):
  21. default_detail = 'The response is empty. Maybe the sample data is not appropriate.' \
  22. 'Please specify another sample data which returns at least one label.'