194 lines
4.4 KiB
Rust
Raw Normal View History

2021-12-14 18:04:51 +08:00
use flowy_derive::ProtoBuf_Enum;
2023-01-30 11:11:19 +08:00
use serde_repr::*;
use thiserror::Error;
2021-12-14 18:04:51 +08:00
2023-01-30 11:11:19 +08:00
#[derive(Debug, Clone, PartialEq, Eq, Error, Serialize_repr, Deserialize_repr, ProtoBuf_Enum)]
#[repr(u8)]
2021-12-14 18:04:51 +08:00
pub enum ErrorCode {
#[error("Internal error")]
2022-01-23 12:14:00 +08:00
Internal = 0,
2021-12-14 18:04:51 +08:00
#[error("Unauthorized user")]
2022-01-23 12:14:00 +08:00
UserUnauthorized = 2,
2021-12-14 18:04:51 +08:00
#[error("Record not found")]
2022-01-23 12:14:00 +08:00
RecordNotFound = 3,
2021-12-14 18:04:51 +08:00
#[error("User id is empty")]
2022-03-19 16:23:34 +08:00
UserIdIsEmpty = 4,
#[error("Workspace name can not be empty or whitespace")]
WorkspaceNameInvalid = 5,
2021-12-14 18:04:51 +08:00
#[error("Workspace id can not be empty or whitespace")]
WorkspaceIdInvalid = 6,
2021-12-14 18:04:51 +08:00
#[error("Color style of the App is invalid")]
AppColorStyleInvalid = 7,
2021-12-14 18:04:51 +08:00
#[error("Workspace desc is invalid")]
WorkspaceDescTooLong = 8,
2021-12-14 18:04:51 +08:00
#[error("Workspace description too long")]
WorkspaceNameTooLong = 9,
2021-12-14 18:04:51 +08:00
#[error("App id can not be empty or whitespace")]
AppIdInvalid = 10,
2021-12-14 18:04:51 +08:00
#[error("App name can not be empty or whitespace")]
AppNameInvalid = 11,
2021-12-14 18:04:51 +08:00
#[error("View name can not be empty or whitespace")]
ViewNameInvalid = 12,
2021-12-14 18:04:51 +08:00
#[error("Thumbnail of the view is invalid")]
ViewThumbnailInvalid = 13,
2021-12-14 18:04:51 +08:00
#[error("View id can not be empty or whitespace")]
ViewIdInvalid = 14,
2021-12-14 18:04:51 +08:00
#[error("View desc too long")]
ViewDescTooLong = 15,
2021-12-14 18:04:51 +08:00
#[error("View data is invalid")]
ViewDataInvalid = 16,
2021-12-14 18:04:51 +08:00
#[error("View name too long")]
ViewNameTooLong = 17,
2021-12-14 18:04:51 +08:00
#[error("Http server connection error")]
HttpServerConnectError = 18,
2021-12-14 18:04:51 +08:00
#[error("Email can not be empty or whitespace")]
EmailIsEmpty = 19,
#[error("Email format is not valid")]
EmailFormatInvalid = 20,
#[error("Email already exists")]
EmailAlreadyExists = 21,
#[error("Password can not be empty or whitespace")]
PasswordIsEmpty = 22,
#[error("Password format too long")]
PasswordTooLong = 23,
#[error("Password contains forbidden characters.")]
PasswordContainsForbidCharacters = 24,
#[error("Password should contain a minimum of 6 characters with 1 special 1 letter and 1 numeric")]
PasswordFormatInvalid = 25,
#[error("Password not match")]
PasswordNotMatch = 26,
#[error("User name is too long")]
UserNameTooLong = 27,
#[error("User name contain forbidden characters")]
UserNameContainForbiddenCharacters = 28,
#[error("User name can not be empty or whitespace")]
UserNameIsEmpty = 29,
#[error("user id is empty or whitespace")]
UserIdInvalid = 30,
2023-01-30 11:11:19 +08:00
#[error("User not exist")]
UserNotExist = 31,
#[error("Text is too long")]
TextTooLong = 32,
#[error("Grid id is empty")]
GridIdIsEmpty = 33,
#[error("Grid view id is empty")]
GridViewIdIsEmpty = 34,
2022-08-16 15:49:54 +08:00
#[error("Grid block id is empty")]
BlockIdIsEmpty = 35,
#[error("Row id is empty")]
RowIdIsEmpty = 36,
#[error("Select option id is empty")]
OptionIdIsEmpty = 37,
#[error("Field id is empty")]
FieldIdIsEmpty = 38,
#[error("Field doesn't exist")]
FieldDoesNotExist = 39,
#[error("The name of the option should not be empty")]
SelectOptionNameIsEmpty = 40,
#[error("Field not exists")]
FieldNotExists = 41,
#[error("The operation in this field is invalid")]
FieldInvalidOperation = 42,
#[error("Filter id is empty")]
FilterIdIsEmpty = 43,
#[error("Field is not exist")]
FieldRecordNotFound = 44,
2022-03-27 09:35:10 +08:00
#[error("Field's type-option data should not be empty")]
TypeOptionDataIsEmpty = 45,
#[error("Group id is empty")]
GroupIdIsEmpty = 46,
#[error("Invalid date time format")]
InvalidDateTimeFormat = 47,
2022-05-13 22:58:49 +08:00
#[error("The input string is empty or contains invalid characters")]
UnexpectedEmptyString = 48,
2022-06-15 11:43:24 +08:00
#[error("Invalid data")]
InvalidData = 49,
#[error("Serde")]
Serde = 50,
#[error("Protobuf serde")]
ProtobufSerde = 51,
2022-11-15 13:04:30 +08:00
#[error("Out of bounds")]
OutOfBounds = 52,
#[error("Sort id is empty")]
SortIdIsEmpty = 53,
2023-01-30 11:11:19 +08:00
#[error("Connect refused")]
ConnectRefused = 54,
#[error("Connection timeout")]
ConnectTimeout = 55,
#[error("Connection closed")]
ConnectClose = 56,
#[error("Connection canceled")]
ConnectCancel = 57,
#[error("Sql error")]
SqlError = 58,
#[error("Http request error")]
HttpError = 59,
#[error("Payload should not be empty")]
UnexpectedEmptyPayload = 60,
2021-12-14 18:04:51 +08:00
}
impl ErrorCode {
pub fn value(&self) -> i32 {
self.clone() as i32
2021-12-14 18:04:51 +08:00
}
}