|
1 | 1 | use crate::protobuf::ErrorCode as ProtoBufErrorCode; |
2 | | -use derive_more::Display; |
3 | 2 | use flowy_derive::ProtoBuf_Enum; |
4 | 3 | use protobuf::ProtobufEnum; |
5 | 4 | use std::convert::{TryFrom, TryInto}; |
| 5 | +use thiserror::Error; |
6 | 6 |
|
7 | | -#[derive(Debug, Clone, ProtoBuf_Enum, Display, PartialEq, Eq)] |
| 7 | +#[derive(Debug, Clone, ProtoBuf_Enum, PartialEq, Eq, Error)] |
8 | 8 | pub enum ErrorCode { |
9 | | - #[display(fmt = "Internal error")] |
| 9 | + #[error("Internal error")] |
10 | 10 | Internal = 0, |
11 | 11 |
|
12 | | - #[display(fmt = "UserUnauthorized")] |
| 12 | + #[error("UserUnauthorized")] |
13 | 13 | UserUnauthorized = 2, |
14 | 14 |
|
15 | | - #[display(fmt = "RecordNotFound")] |
| 15 | + #[error("RecordNotFound")] |
16 | 16 | RecordNotFound = 3, |
17 | 17 |
|
18 | | - #[display(fmt = "User id is empty")] |
| 18 | + #[error("User id is empty")] |
19 | 19 | UserIdIsEmpty = 4, |
20 | 20 |
|
21 | | - #[display(fmt = "Workspace name can not be empty or whitespace")] |
| 21 | + #[error("Workspace name can not be empty or whitespace")] |
22 | 22 | WorkspaceNameInvalid = 100, |
23 | 23 |
|
24 | | - #[display(fmt = "Workspace id can not be empty or whitespace")] |
| 24 | + #[error("Workspace id can not be empty or whitespace")] |
25 | 25 | WorkspaceIdInvalid = 101, |
26 | 26 |
|
27 | | - #[display(fmt = "Color style of the App is invalid")] |
| 27 | + #[error("Color style of the App is invalid")] |
28 | 28 | AppColorStyleInvalid = 102, |
29 | 29 |
|
30 | | - #[display(fmt = "Workspace desc is invalid")] |
| 30 | + #[error("Workspace desc is invalid")] |
31 | 31 | WorkspaceDescTooLong = 103, |
32 | 32 |
|
33 | | - #[display(fmt = "Workspace description too long")] |
| 33 | + #[error("Workspace description too long")] |
34 | 34 | WorkspaceNameTooLong = 104, |
35 | 35 |
|
36 | | - #[display(fmt = "App id can not be empty or whitespace")] |
| 36 | + #[error("App id can not be empty or whitespace")] |
37 | 37 | AppIdInvalid = 110, |
38 | 38 |
|
39 | | - #[display(fmt = "App name can not be empty or whitespace")] |
| 39 | + #[error("App name can not be empty or whitespace")] |
40 | 40 | AppNameInvalid = 111, |
41 | 41 |
|
42 | | - #[display(fmt = "View name can not be empty or whitespace")] |
| 42 | + #[error("View name can not be empty or whitespace")] |
43 | 43 | ViewNameInvalid = 120, |
44 | 44 |
|
45 | | - #[display(fmt = "Thumbnail of the view is invalid")] |
| 45 | + #[error("Thumbnail of the view is invalid")] |
46 | 46 | ViewThumbnailInvalid = 121, |
47 | 47 |
|
48 | | - #[display(fmt = "View id can not be empty or whitespace")] |
| 48 | + #[error("View id can not be empty or whitespace")] |
49 | 49 | ViewIdInvalid = 122, |
50 | 50 |
|
51 | | - #[display(fmt = "View desc too long")] |
| 51 | + #[error("View desc too long")] |
52 | 52 | ViewDescTooLong = 123, |
53 | 53 |
|
54 | | - #[display(fmt = "View data is invalid")] |
| 54 | + #[error("View data is invalid")] |
55 | 55 | ViewDataInvalid = 124, |
56 | 56 |
|
57 | | - #[display(fmt = "View name too long")] |
| 57 | + #[error("View name too long")] |
58 | 58 | ViewNameTooLong = 125, |
59 | 59 |
|
60 | | - #[display(fmt = "Connection error")] |
| 60 | + #[error("Connection error")] |
61 | 61 | ConnectError = 200, |
62 | 62 |
|
63 | | - #[display(fmt = "Email can not be empty or whitespace")] |
| 63 | + #[error("Email can not be empty or whitespace")] |
64 | 64 | EmailIsEmpty = 300, |
65 | | - #[display(fmt = "Email format is not valid")] |
| 65 | + #[error("Email format is not valid")] |
66 | 66 | EmailFormatInvalid = 301, |
67 | | - #[display(fmt = "Email already exists")] |
| 67 | + #[error("Email already exists")] |
68 | 68 | EmailAlreadyExists = 302, |
69 | | - #[display(fmt = "Password can not be empty or whitespace")] |
| 69 | + #[error("Password can not be empty or whitespace")] |
70 | 70 | PasswordIsEmpty = 303, |
71 | | - #[display(fmt = "Password format too long")] |
| 71 | + #[error("Password format too long")] |
72 | 72 | PasswordTooLong = 304, |
73 | | - #[display(fmt = "Password contains forbidden characters.")] |
| 73 | + #[error("Password contains forbidden characters.")] |
74 | 74 | PasswordContainsForbidCharacters = 305, |
75 | | - #[display(fmt = "Password should contain a minimum of 6 characters with 1 special 1 letter and 1 numeric")] |
| 75 | + #[error("Password should contain a minimum of 6 characters with 1 special 1 letter and 1 numeric")] |
76 | 76 | PasswordFormatInvalid = 306, |
77 | | - #[display(fmt = "Password not match")] |
| 77 | + #[error("Password not match")] |
78 | 78 | PasswordNotMatch = 307, |
79 | | - #[display(fmt = "User name is too long")] |
| 79 | + #[error("User name is too long")] |
80 | 80 | UserNameTooLong = 308, |
81 | | - #[display(fmt = "User name contain forbidden characters")] |
| 81 | + #[error("User name contain forbidden characters")] |
82 | 82 | UserNameContainForbiddenCharacters = 309, |
83 | | - #[display(fmt = "User name can not be empty or whitespace")] |
| 83 | + #[error("User name can not be empty or whitespace")] |
84 | 84 | UserNameIsEmpty = 310, |
85 | | - #[display(fmt = "user id is empty or whitespace")] |
| 85 | + #[error("user id is empty or whitespace")] |
86 | 86 | UserIdInvalid = 311, |
87 | | - #[display(fmt = "User not exist")] |
| 87 | + #[error("User not exist")] |
88 | 88 | UserNotExist = 312, |
89 | | - #[display(fmt = "Text is too long")] |
| 89 | + #[error("Text is too long")] |
90 | 90 | TextTooLong = 400, |
91 | 91 |
|
92 | | - #[display(fmt = "Grid id is empty")] |
| 92 | + #[error("Grid id is empty")] |
93 | 93 | GridIdIsEmpty = 410, |
94 | | - #[display(fmt = "Grid view id is empty")] |
| 94 | + #[error("Grid view id is empty")] |
95 | 95 | GridViewIdIsEmpty = 411, |
96 | 96 |
|
97 | | - #[display(fmt = "Grid block id is empty")] |
| 97 | + #[error("Grid block id is empty")] |
98 | 98 | BlockIdIsEmpty = 420, |
99 | | - #[display(fmt = "Row id is empty")] |
| 99 | + #[error("Row id is empty")] |
100 | 100 | RowIdIsEmpty = 430, |
101 | | - #[display(fmt = "Select option id is empty")] |
| 101 | + #[error("Select option id is empty")] |
102 | 102 | OptionIdIsEmpty = 431, |
103 | | - #[display(fmt = "Field id is empty")] |
| 103 | + #[error("Field id is empty")] |
104 | 104 | FieldIdIsEmpty = 440, |
105 | | - #[display(fmt = "Field doesn't exist")] |
| 105 | + #[error("Field doesn't exist")] |
106 | 106 | FieldDoesNotExist = 441, |
107 | | - #[display(fmt = "The name of the option should not be empty")] |
| 107 | + #[error("The name of the option should not be empty")] |
108 | 108 | SelectOptionNameIsEmpty = 442, |
109 | | - #[display(fmt = "Field not exists")] |
| 109 | + #[error("Field not exists")] |
110 | 110 | FieldNotExists = 443, |
111 | | - #[display(fmt = "The operation in this field is invalid")] |
| 111 | + #[error("The operation in this field is invalid")] |
112 | 112 | FieldInvalidOperation = 444, |
113 | | - #[display(fmt = "Filter id is empty")] |
| 113 | + #[error("Filter id is empty")] |
114 | 114 | FilterIdIsEmpty = 445, |
115 | | - #[display(fmt = "Field is not exist")] |
| 115 | + #[error("Field is not exist")] |
116 | 116 | FieldRecordNotFound = 446, |
117 | 117 |
|
118 | | - #[display(fmt = "Field's type-option data should not be empty")] |
| 118 | + #[error("Field's type-option data should not be empty")] |
119 | 119 | TypeOptionDataIsEmpty = 450, |
120 | 120 |
|
121 | | - #[display(fmt = "Group id is empty")] |
| 121 | + #[error("Group id is empty")] |
122 | 122 | GroupIdIsEmpty = 460, |
123 | 123 |
|
124 | | - #[display(fmt = "Invalid date time format")] |
| 124 | + #[error("Invalid date time format")] |
125 | 125 | InvalidDateTimeFormat = 500, |
126 | 126 |
|
127 | | - #[display(fmt = "The input string is empty or contains invalid characters")] |
| 127 | + #[error("The input string is empty or contains invalid characters")] |
128 | 128 | UnexpectedEmptyString = 999, |
129 | 129 |
|
130 | | - #[display(fmt = "Invalid data")] |
| 130 | + #[error("Invalid data")] |
131 | 131 | InvalidData = 1000, |
132 | 132 |
|
133 | | - #[display(fmt = "Serde")] |
| 133 | + #[error("Serde")] |
134 | 134 | Serde = 1001, |
135 | 135 |
|
136 | | - #[display(fmt = "Protobuf serde")] |
| 136 | + #[error("Protobuf serde")] |
137 | 137 | ProtobufSerde = 1002, |
138 | 138 |
|
139 | | - #[display(fmt = "Out of bounds")] |
| 139 | + #[error("Out of bounds")] |
140 | 140 | OutOfBounds = 10001, |
141 | 141 | } |
142 | 142 |
|
|
0 commit comments