Skip to content

Commit 6fd9e0c

Browse files
Seulgi Kimmajecty
authored andcommitted
Reorganize the error ids
1 parent 542f0e0 commit 6fd9e0c

File tree

3 files changed

+54
-54
lines changed

3 files changed

+54
-54
lines changed

types/src/errors/history_error.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ pub enum Error {
3535
#[derive(Clone, Copy)]
3636
#[repr(u8)]
3737
enum ErrorID {
38-
LimitReached = 2,
39-
Old = 3,
40-
TooCheapToReplace = 6,
41-
TxAlreadyImported = 7,
38+
LimitReached = 1,
39+
Old = 2,
40+
TooCheapToReplace = 3,
41+
TxAlreadyImported = 4,
4242
}
4343

4444
impl Encodable for ErrorID {
@@ -51,10 +51,10 @@ impl Decodable for ErrorID {
5151
fn decode(rlp: &Rlp) -> Result<Self, DecoderError> {
5252
let tag = rlp.as_val()?;
5353
match tag {
54-
2u8 => Ok(ErrorID::LimitReached),
55-
3 => Ok(ErrorID::Old),
56-
6 => Ok(ErrorID::TooCheapToReplace),
57-
7 => Ok(ErrorID::TxAlreadyImported),
54+
1u8 => Ok(ErrorID::LimitReached),
55+
2 => Ok(ErrorID::Old),
56+
3 => Ok(ErrorID::TooCheapToReplace),
57+
4 => Ok(ErrorID::TxAlreadyImported),
5858
_ => Err(DecoderError::Custom("Unexpected ErrorID Value")),
5959
}
6060
}

types/src/errors/runtime_error.rs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use std::fmt::{Display, Formatter, Result as FormatResult};
2424
#[derive(Debug, PartialEq, Clone, Eq, Serialize)]
2525
#[serde(tag = "type", content = "content")]
2626
pub enum Error {
27-
FailedToHandleCustomAction(String),
2827
/// Sender doesn't have enough funds to pay for this Transaction
2928
InsufficientBalance {
3029
address: Address,
@@ -35,18 +34,19 @@ pub enum Error {
3534
},
3635
InsufficientPermission,
3736
/// Returned when transaction seq does not match state seq
38-
InvalidSeq(Mismatch<u64>),
3937
InvalidShardId(ShardId),
4038
InvalidTransferDestination,
4139
NewOwnersMustContainSender,
4240
RegularKeyAlreadyInUse,
4341
RegularKeyAlreadyInUseAsPlatformAccount,
4442
/// Tried to use master key even register key is registered
4543
CannotUseMasterKey,
44+
InvalidSeq(Mismatch<u64>),
4645
NonActiveAccount {
4746
address: Address,
4847
name: String,
4948
},
49+
FailedToHandleCustomAction(String),
5050
SignatureOfInvalidAccount(Address),
5151
InsufficientStakes(Mismatch<u64>),
5252
InvalidValidatorIndex {
@@ -58,20 +58,20 @@ pub enum Error {
5858
#[derive(Clone, Copy)]
5959
#[repr(u8)]
6060
enum ErrorID {
61-
InsufficientBalance = 8,
62-
InsufficientPermission = 9,
63-
InvalidShardID = 15,
64-
InvalidTransferDestination = 16,
65-
NewOwnersMustContainSender = 17,
66-
RegularKeyAlreadyInUse = 19,
67-
RegularKeyAlreadyInUseAsPlatform = 20,
68-
CannotUseMasterKey = 25,
69-
InvalidSeq = 28,
70-
NonActiveAccount = 30,
71-
FailedToHandleCustomAction = 31,
72-
SignatureOfInvalid = 32,
73-
InsufficientStakes = 33,
74-
InvalidValidatorIndex = 34,
61+
InsufficientBalance = 1,
62+
InsufficientPermission = 2,
63+
InvalidShardID = 3,
64+
InvalidTransferDestination = 4,
65+
NewOwnersMustContainSender = 5,
66+
RegularKeyAlreadyInUse = 6,
67+
RegularKeyAlreadyInUseAsPlatform = 7,
68+
CannotUseMasterKey = 8,
69+
InvalidSeq = 9,
70+
NonActiveAccount = 10,
71+
FailedToHandleCustomAction = 11,
72+
SignatureOfInvalid = 12,
73+
InsufficientStakes = 13,
74+
InvalidValidatorIndex = 14,
7575
}
7676

7777
impl Encodable for ErrorID {
@@ -84,20 +84,20 @@ impl Decodable for ErrorID {
8484
fn decode(rlp: &Rlp) -> Result<Self, DecoderError> {
8585
let tag = rlp.as_val()?;
8686
match tag {
87-
8u8 => Ok(ErrorID::FailedToHandleCustomAction),
88-
10 => Ok(ErrorID::InsufficientBalance),
89-
11 => Ok(ErrorID::InsufficientPermission),
90-
18 => Ok(ErrorID::InvalidSeq),
91-
19 => Ok(ErrorID::InvalidShardID),
92-
20 => Ok(ErrorID::InvalidTransferDestination),
93-
21 => Ok(ErrorID::NewOwnersMustContainSender),
94-
23 => Ok(ErrorID::RegularKeyAlreadyInUse),
95-
24 => Ok(ErrorID::RegularKeyAlreadyInUseAsPlatform),
96-
30 => Ok(ErrorID::CannotUseMasterKey),
97-
31 => Ok(ErrorID::NonActiveAccount),
98-
32 => Ok(ErrorID::SignatureOfInvalid),
99-
33 => Ok(ErrorID::InsufficientStakes),
100-
34 => Ok(ErrorID::InvalidValidatorIndex),
87+
1u8 => Ok(ErrorID::InsufficientBalance),
88+
2 => Ok(ErrorID::InsufficientPermission),
89+
3 => Ok(ErrorID::InvalidShardID),
90+
4 => Ok(ErrorID::InvalidTransferDestination),
91+
5 => Ok(ErrorID::NewOwnersMustContainSender),
92+
6 => Ok(ErrorID::RegularKeyAlreadyInUse),
93+
7 => Ok(ErrorID::RegularKeyAlreadyInUseAsPlatform),
94+
8 => Ok(ErrorID::CannotUseMasterKey),
95+
9 => Ok(ErrorID::InvalidSeq),
96+
10 => Ok(ErrorID::NonActiveAccount),
97+
11 => Ok(ErrorID::FailedToHandleCustomAction),
98+
12 => Ok(ErrorID::SignatureOfInvalid),
99+
13 => Ok(ErrorID::InsufficientStakes),
100+
14 => Ok(ErrorID::InvalidValidatorIndex),
101101
_ => Err(DecoderError::Custom("Unexpected ActionTag Value")),
102102
}
103103
}

types/src/errors/syntax_error.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ pub enum Error {
4444
#[derive(Clone, Copy)]
4545
#[repr(u8)]
4646
enum ErrorID {
47-
EmptyShardOwners = 4,
48-
InsufficientFee = 7,
49-
InvalidNetworkID = 11,
50-
InvalidApproval = 21,
51-
MetadataTooBig = 22,
52-
TextContentTooBig = 24,
53-
TxIsTooBig = 27,
54-
InvalidCustomAction = 32,
47+
EmptyShardOwners = 1,
48+
InsufficientFee = 2,
49+
InvalidNetworkID = 3,
50+
InvalidApproval = 4,
51+
MetadataTooBig = 5,
52+
TextContentTooBig = 6,
53+
TxIsTooBig = 7,
54+
InvalidCustomAction = 8,
5555
}
5656

5757
impl Encodable for ErrorID {
@@ -64,14 +64,14 @@ impl Decodable for ErrorID {
6464
fn decode(rlp: &Rlp) -> Result<Self, DecoderError> {
6565
let tag = rlp.as_val()?;
6666
match tag {
67-
4u8 => Ok(ErrorID::EmptyShardOwners),
68-
7 => Ok(ErrorID::InsufficientFee),
69-
11 => Ok(ErrorID::InvalidNetworkID),
70-
21 => Ok(ErrorID::InvalidApproval),
71-
22 => Ok(ErrorID::MetadataTooBig),
72-
24 => Ok(ErrorID::TextContentTooBig),
73-
27 => Ok(ErrorID::TxIsTooBig),
74-
32 => Ok(ErrorID::InvalidCustomAction),
67+
1u8 => Ok(ErrorID::EmptyShardOwners),
68+
2 => Ok(ErrorID::InsufficientFee),
69+
3 => Ok(ErrorID::InvalidNetworkID),
70+
4 => Ok(ErrorID::InvalidApproval),
71+
5 => Ok(ErrorID::MetadataTooBig),
72+
6 => Ok(ErrorID::TextContentTooBig),
73+
7 => Ok(ErrorID::TxIsTooBig),
74+
8 => Ok(ErrorID::InvalidCustomAction),
7575
_ => Err(DecoderError::Custom("Unexpected ErrorID Value")),
7676
}
7777
}

0 commit comments

Comments
 (0)