code.rs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. use flowy_derive::ProtoBuf_Enum;
  2. use thiserror::Error;
  3. #[derive(Debug, Clone, PartialEq, Eq, Error, ProtoBuf_Enum)]
  4. pub enum ErrorCode {
  5. #[error("Internal error")]
  6. Internal = 0,
  7. #[error("Unauthorized user")]
  8. UserUnauthorized = 2,
  9. #[error("Record not found")]
  10. RecordNotFound = 3,
  11. #[error("User id is empty")]
  12. UserIdIsEmpty = 4,
  13. #[error("Workspace name can not be empty or whitespace")]
  14. WorkspaceNameInvalid = 5,
  15. #[error("Workspace id can not be empty or whitespace")]
  16. WorkspaceIdInvalid = 6,
  17. #[error("Color style of the App is invalid")]
  18. AppColorStyleInvalid = 7,
  19. #[error("Workspace desc is invalid")]
  20. WorkspaceDescTooLong = 8,
  21. #[error("Workspace description too long")]
  22. WorkspaceNameTooLong = 9,
  23. #[error("App id can not be empty or whitespace")]
  24. AppIdInvalid = 10,
  25. #[error("App name can not be empty or whitespace")]
  26. AppNameInvalid = 11,
  27. #[error("View name can not be empty or whitespace")]
  28. ViewNameInvalid = 12,
  29. #[error("Thumbnail of the view is invalid")]
  30. ViewThumbnailInvalid = 13,
  31. #[error("View id can not be empty or whitespace")]
  32. ViewIdInvalid = 14,
  33. #[error("View desc too long")]
  34. ViewDescTooLong = 15,
  35. #[error("View data is invalid")]
  36. ViewDataInvalid = 16,
  37. #[error("View name too long")]
  38. ViewNameTooLong = 17,
  39. #[error("Http server connection error")]
  40. HttpServerConnectError = 18,
  41. #[error("Email can not be empty or whitespace")]
  42. EmailIsEmpty = 19,
  43. #[error("Email format is not valid")]
  44. EmailFormatInvalid = 20,
  45. #[error("Email already exists")]
  46. EmailAlreadyExists = 21,
  47. #[error("Password can not be empty or whitespace")]
  48. PasswordIsEmpty = 22,
  49. #[error("Password format too long")]
  50. PasswordTooLong = 23,
  51. #[error("Password contains forbidden characters.")]
  52. PasswordContainsForbidCharacters = 24,
  53. #[error("Password should contain a minimum of 6 characters with 1 special 1 letter and 1 numeric")]
  54. PasswordFormatInvalid = 25,
  55. #[error("Password not match")]
  56. PasswordNotMatch = 26,
  57. #[error("User name is too long")]
  58. UserNameTooLong = 27,
  59. #[error("User name contain forbidden characters")]
  60. UserNameContainForbiddenCharacters = 28,
  61. #[error("User name can not be empty or whitespace")]
  62. UserNameIsEmpty = 29,
  63. #[error("user id is empty or whitespace")]
  64. UserIdInvalid = 30,
  65. #[error("User not exist")]
  66. UserNotExist = 31,
  67. #[error("Text is too long")]
  68. TextTooLong = 32,
  69. #[error("Grid id is empty")]
  70. GridIdIsEmpty = 33,
  71. #[error("Grid view id is empty")]
  72. GridViewIdIsEmpty = 34,
  73. #[error("Grid block id is empty")]
  74. BlockIdIsEmpty = 35,
  75. #[error("Row id is empty")]
  76. RowIdIsEmpty = 36,
  77. #[error("Select option id is empty")]
  78. OptionIdIsEmpty = 37,
  79. #[error("Field id is empty")]
  80. FieldIdIsEmpty = 38,
  81. #[error("Field doesn't exist")]
  82. FieldDoesNotExist = 39,
  83. #[error("The name of the option should not be empty")]
  84. SelectOptionNameIsEmpty = 40,
  85. #[error("Field not exists")]
  86. FieldNotExists = 41,
  87. #[error("The operation in this field is invalid")]
  88. FieldInvalidOperation = 42,
  89. #[error("Filter id is empty")]
  90. FilterIdIsEmpty = 43,
  91. #[error("Field is not exist")]
  92. FieldRecordNotFound = 44,
  93. #[error("Field's type-option data should not be empty")]
  94. TypeOptionDataIsEmpty = 45,
  95. #[error("Group id is empty")]
  96. GroupIdIsEmpty = 46,
  97. #[error("Invalid date time format")]
  98. InvalidDateTimeFormat = 47,
  99. #[error("The input string is empty or contains invalid characters")]
  100. UnexpectedEmptyString = 48,
  101. #[error("Invalid data")]
  102. InvalidData = 49,
  103. #[error("Serde")]
  104. Serde = 50,
  105. #[error("Protobuf serde")]
  106. ProtobufSerde = 51,
  107. #[error("Out of bounds")]
  108. OutOfBounds = 52,
  109. }
  110. impl ErrorCode {
  111. pub fn value(&self) -> i32 {
  112. self.clone() as i32
  113. }
  114. }