error.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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