Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

error.py 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. from libs.exception import BaseHTTPException
  2. class ApiKeyAuthFailedError(BaseHTTPException):
  3. error_code = "auth_failed"
  4. description = "{message}"
  5. code = 500
  6. class InvalidEmailError(BaseHTTPException):
  7. error_code = "invalid_email"
  8. description = "The email address is not valid."
  9. code = 400
  10. class PasswordMismatchError(BaseHTTPException):
  11. error_code = "password_mismatch"
  12. description = "The passwords do not match."
  13. code = 400
  14. class InvalidTokenError(BaseHTTPException):
  15. error_code = "invalid_or_expired_token"
  16. description = "The token is invalid or has expired."
  17. code = 400
  18. class PasswordResetRateLimitExceededError(BaseHTTPException):
  19. error_code = "password_reset_rate_limit_exceeded"
  20. description = "Too many password reset emails have been sent. Please try again in 1 minute."
  21. code = 429
  22. class EmailChangeRateLimitExceededError(BaseHTTPException):
  23. error_code = "email_change_rate_limit_exceeded"
  24. description = "Too many email change emails have been sent. Please try again in 1 minute."
  25. code = 429
  26. class OwnerTransferRateLimitExceededError(BaseHTTPException):
  27. error_code = "owner_transfer_rate_limit_exceeded"
  28. description = "Too many owner transfer emails have been sent. Please try again in 1 minute."
  29. code = 429
  30. class EmailCodeError(BaseHTTPException):
  31. error_code = "email_code_error"
  32. description = "Email code is invalid or expired."
  33. code = 400
  34. class EmailOrPasswordMismatchError(BaseHTTPException):
  35. error_code = "email_or_password_mismatch"
  36. description = "The email or password is mismatched."
  37. code = 400
  38. class EmailPasswordLoginLimitError(BaseHTTPException):
  39. error_code = "email_code_login_limit"
  40. description = "Too many incorrect password attempts. Please try again later."
  41. code = 429
  42. class EmailCodeLoginRateLimitExceededError(BaseHTTPException):
  43. error_code = "email_code_login_rate_limit_exceeded"
  44. description = "Too many login emails have been sent. Please try again in 5 minutes."
  45. code = 429
  46. class EmailCodeAccountDeletionRateLimitExceededError(BaseHTTPException):
  47. error_code = "email_code_account_deletion_rate_limit_exceeded"
  48. description = "Too many account deletion emails have been sent. Please try again in 5 minutes."
  49. code = 429
  50. class EmailPasswordResetLimitError(BaseHTTPException):
  51. error_code = "email_password_reset_limit"
  52. description = "Too many failed password reset attempts. Please try again in 24 hours."
  53. code = 429
  54. class EmailChangeLimitError(BaseHTTPException):
  55. error_code = "email_change_limit"
  56. description = "Too many failed email change attempts. Please try again in 24 hours."
  57. code = 429
  58. class EmailAlreadyInUseError(BaseHTTPException):
  59. error_code = "email_already_in_use"
  60. description = "A user with this email already exists."
  61. code = 400
  62. class OwnerTransferLimitError(BaseHTTPException):
  63. error_code = "owner_transfer_limit"
  64. description = "Too many failed owner transfer attempts. Please try again in 24 hours."
  65. code = 429
  66. class NotOwnerError(BaseHTTPException):
  67. error_code = "not_owner"
  68. description = "You are not the owner of the workspace."
  69. code = 400
  70. class CannotTransferOwnerToSelfError(BaseHTTPException):
  71. error_code = "cannot_transfer_owner_to_self"
  72. description = "You cannot transfer ownership to yourself."
  73. code = 400
  74. class MemberNotInTenantError(BaseHTTPException):
  75. error_code = "member_not_in_tenant"
  76. description = "The member is not in the workspace."
  77. code = 400