error.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 WebsiteCrawlError(BaseHTTPException):
  51. error_code = "crawl_failed"
  52. description = "{message}"
  53. code = 500
  54. class DatasetInUseError(BaseHTTPException):
  55. error_code = "dataset_in_use"
  56. description = "The dataset is being used by some apps. Please remove the dataset from the apps before deleting it."
  57. code = 409
  58. class IndexingEstimateError(BaseHTTPException):
  59. error_code = "indexing_estimate_error"
  60. description = "Knowledge indexing estimate failed: {message}"
  61. code = 500
  62. class ChildChunkIndexingError(BaseHTTPException):
  63. error_code = "child_chunk_indexing_error"
  64. description = "Create child chunk index failed: {message}"
  65. code = 500
  66. class ChildChunkDeleteIndexError(BaseHTTPException):
  67. error_code = "child_chunk_delete_index_error"
  68. description = "Delete child chunk index failed: {message}"
  69. code = 500