error.py 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. from libs.exception import BaseHTTPException
  2. class NoFileUploadedError(BaseHTTPException):
  3. error_code = "no_file_uploaded"
  4. description = "Please upload your file."
  5. code = 400
  6. class TooManyFilesError(BaseHTTPException):
  7. error_code = "too_many_files"
  8. description = "Only one file is allowed."
  9. code = 400
  10. class FileTooLargeError(BaseHTTPException):
  11. error_code = "file_too_large"
  12. description = "File size exceeded. {message}"
  13. code = 413
  14. class UnsupportedFileTypeError(BaseHTTPException):
  15. error_code = "unsupported_file_type"
  16. description = "File type not allowed."
  17. code = 415
  18. class HighQualityDatasetOnlyError(BaseHTTPException):
  19. error_code = "high_quality_dataset_only"
  20. description = "Current operation only supports 'high-quality' datasets."
  21. code = 400
  22. class DatasetNotInitializedError(BaseHTTPException):
  23. error_code = "dataset_not_initialized"
  24. description = "The dataset is still being initialized or indexing. Please wait a moment."
  25. code = 400
  26. class ArchivedDocumentImmutableError(BaseHTTPException):
  27. error_code = "archived_document_immutable"
  28. description = "The archived document is not editable."
  29. code = 403
  30. class DatasetNameDuplicateError(BaseHTTPException):
  31. error_code = "dataset_name_duplicate"
  32. description = "The dataset name already exists. Please modify your dataset name."
  33. code = 409
  34. class InvalidActionError(BaseHTTPException):
  35. error_code = "invalid_action"
  36. description = "Invalid action."
  37. code = 400
  38. class DocumentAlreadyFinishedError(BaseHTTPException):
  39. error_code = "document_already_finished"
  40. description = "The document has been processed. Please refresh the page or go to the document details."
  41. code = 400
  42. class DocumentIndexingError(BaseHTTPException):
  43. error_code = "document_indexing"
  44. description = "The document is being processed and cannot be edited."
  45. code = 400
  46. class InvalidMetadataError(BaseHTTPException):
  47. error_code = "invalid_metadata"
  48. description = "The metadata content is incorrect. Please check and verify."
  49. code = 400
  50. class DatasetInUseError(BaseHTTPException):
  51. error_code = "dataset_in_use"
  52. description = "The dataset is being used by some apps. Please remove the dataset from the apps before deleting it."
  53. code = 409