error.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. from libs.exception import BaseHTTPException
  2. class AlreadySetupError(BaseHTTPException):
  3. error_code = "already_setup"
  4. description = "Dify has been successfully installed. Please refresh the page or return to the dashboard homepage."
  5. code = 403
  6. class NotSetupError(BaseHTTPException):
  7. error_code = "not_setup"
  8. description = (
  9. "Dify has not been initialized and installed yet. "
  10. "Please proceed with the initialization and installation process first."
  11. )
  12. code = 401
  13. class NotInitValidateError(BaseHTTPException):
  14. error_code = "not_init_validated"
  15. description = "Init validation has not been completed yet. Please proceed with the init validation process first."
  16. code = 401
  17. class InitValidateFailedError(BaseHTTPException):
  18. error_code = "init_validate_failed"
  19. description = "Init validation failed. Please check the password and try again."
  20. code = 401
  21. class AccountNotLinkTenantError(BaseHTTPException):
  22. error_code = "account_not_link_tenant"
  23. description = "Account not link tenant."
  24. code = 403
  25. class AlreadyActivateError(BaseHTTPException):
  26. error_code = "already_activate"
  27. description = "Auth Token is invalid or account already activated, please check again."
  28. code = 403
  29. class NotAllowedCreateWorkspace(BaseHTTPException):
  30. error_code = "not_allowed_create_workspace"
  31. description = "Workspace not found, please contact system admin to invite you to join in a workspace."
  32. code = 400
  33. class AccountBannedError(BaseHTTPException):
  34. error_code = "account_banned"
  35. description = "Account is banned."
  36. code = 400
  37. class NotAllowedRegister(BaseHTTPException):
  38. error_code = "unauthorized"
  39. description = "Account not found."
  40. code = 400
  41. class EmailSendIpLimitError(BaseHTTPException):
  42. error_code = "email_send_ip_limit"
  43. description = "Too many emails have been sent from this IP address recently. Please try again later."
  44. code = 429
  45. class FileTooLargeError(BaseHTTPException):
  46. error_code = "file_too_large"
  47. description = "File size exceeded. {message}"
  48. code = 413
  49. class UnsupportedFileTypeError(BaseHTTPException):
  50. error_code = "unsupported_file_type"
  51. description = "File type not allowed."
  52. code = 415
  53. class TooManyFilesError(BaseHTTPException):
  54. error_code = "too_many_files"
  55. description = "Only one file is allowed."
  56. code = 400
  57. class NoFileUploadedError(BaseHTTPException):
  58. error_code = "no_file_uploaded"
  59. description = "Please upload your file."
  60. code = 400