code.rs 4.3 KB

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