@@ -17,66 +17,53 @@ use crate::DispatchError;
17
17
18
18
use derive_try_from_primitive:: TryFromPrimitive ;
19
19
use std:: convert:: { TryFrom , TryInto } ;
20
+ use thiserror:: Error as ThisError ;
20
21
21
- #[ derive( Clone , Copy , Debug , Eq , PartialEq , TryFromPrimitive ) ]
22
+ #[ derive( Clone , Copy , Debug , Eq , PartialEq , ThisError , TryFromPrimitive ) ]
22
23
#[ repr( u8 ) ]
23
24
/// Errors describing failed Registry transactions.
24
25
pub enum RegistryError {
26
+ #[ error( "the provided checkpoint does not exist" ) ]
25
27
InexistentCheckpointId = 0 ,
28
+
29
+ #[ error( "a registered project must have an initial checkpoint" ) ]
30
+ InexistentInitialProjectCheckpoint ,
31
+
32
+ #[ error( "the provided org does not exist" ) ]
26
33
InexistentOrg ,
34
+
35
+ #[ error( "the provided project does not exist" ) ]
36
+ InexistentProjectId ,
37
+
38
+ #[ error( "the provided user does not exist" ) ]
27
39
InexistentUser ,
40
+
41
+ #[ error( "an org with the same ID already exists" ) ]
28
42
DuplicateOrgId ,
43
+
44
+ #[ error( "a project with the same ID already exists" ) ]
29
45
DuplicateProjectId ,
46
+
47
+ #[ error( "a user with the same ID already exists." ) ]
30
48
DuplicateUserId ,
31
- InexistentProjectId ,
49
+
50
+ #[ error( "the provided fee is insufficient" ) ]
32
51
InsufficientFee ,
52
+
53
+ #[ error( "the sender is not a project member" ) ]
33
54
InsufficientSenderPermissions ,
34
- InexistentParentCheckpoint ,
35
- InexistentInitialProjectCheckpoint ,
55
+
56
+ # [ error ( "the provided checkpoint is not a descendant of the project's initial checkpoint" ) ]
36
57
InvalidCheckpointAncestry ,
37
- NonUnregisterableUser ,
38
- UnregisterableOrg ,
39
- UserAccountAssociated ,
40
- }
41
58
42
- impl From < RegistryError > for & ' static str {
43
- fn from ( error : RegistryError ) -> & ' static str {
44
- match error {
45
- RegistryError :: InexistentCheckpointId => "The provided checkpoint does not exist" ,
46
- RegistryError :: InexistentOrg => "The provided org does not exist" ,
47
- RegistryError :: InexistentUser => "The provided user does not exist" ,
48
- RegistryError :: DuplicateOrgId => "An org with the same ID already exists." ,
49
- RegistryError :: DuplicateProjectId => "A project with a similar ID already exists." ,
50
- RegistryError :: DuplicateUserId => "A user with the same ID already exists." ,
51
- RegistryError :: InexistentProjectId => "Project does not exist" ,
52
- RegistryError :: InsufficientFee => "The provided fee is insufficient." ,
53
- RegistryError :: InsufficientSenderPermissions => "Sender is not a project member" ,
54
- RegistryError :: InexistentParentCheckpoint => "Parent checkpoint does not exist" ,
55
- RegistryError :: InexistentInitialProjectCheckpoint => {
56
- "A registered project must have an initial checkpoint."
57
- }
58
- RegistryError :: InvalidCheckpointAncestry => {
59
- "The provided checkpoint is not a descendant of the project's initial checkpoint."
60
- }
61
- RegistryError :: NonUnregisterableUser => {
62
- "The provided user is not eligible for unregistration."
63
- }
64
- RegistryError :: UnregisterableOrg => {
65
- "The provided org is not elibile for unregistration."
66
- }
67
- RegistryError :: UserAccountAssociated => {
68
- "The account is already associated with a user."
69
- }
70
- }
71
- }
72
- }
59
+ #[ error( "the provided user is not eligible for unregistration" ) ]
60
+ UnregisterableUser ,
73
61
74
- #[ cfg( feature = "std" ) ]
75
- impl core:: fmt:: Display for RegistryError {
76
- fn fmt ( & self , f : & mut core:: fmt:: Formatter ) -> core:: fmt:: Result {
77
- let s: & str = self . clone ( ) . into ( ) ;
78
- write ! ( f, "{}" , s)
79
- }
62
+ #[ error( "the provided org is not elibile for unregistration" ) ]
63
+ UnregisterableOrg ,
64
+
65
+ #[ error( "the account is already associated with a user" ) ]
66
+ UserAccountAssociated ,
80
67
}
81
68
82
69
// The index with which the registry runtime module is declared
0 commit comments