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.

27 lines
956 B

  1. from rest_framework import status
  2. from rest_framework.exceptions import APIException
  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 LabelValidationError(APIException):
  11. status_code = status.HTTP_400_BAD_REQUEST
  12. default_detail = 'You cannot create a label with same name or shortcut key.'
  13. class AnnotationRelationValidationError(APIException):
  14. status_code = status.HTTP_400_BAD_REQUEST
  15. default_detail = 'You cannot create an annotation relation between the same annotation.'
  16. class RelationTypesValidationError(APIException):
  17. status_code = status.HTTP_400_BAD_REQUEST
  18. default_detail = 'You cannot create a relation type with same name or color.'