Skip to content

Commit

Permalink
Backfilled error codes for all InvalidTransaction error variants
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Zajkowski committed Dec 17, 2024
1 parent 32aa5db commit 8d63ca2
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion binary_port/src/error_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,27 @@ pub enum ErrorCode {
/// No matching lane for transaction
#[error("couldn't associate a transaction lane with the transaction")]
InvalidTransactionNoWasmLaneMatches = 97,
/// Entry point must be 'call'
#[error("entry point must be 'call'")]
InvalidTransactionEntryPointMustBeCall = 98,
/// One of the payloads field cannot be deserialized
#[error("One of the payloads field cannot be deserialized")]
InvalidTransactionCannotDeserializeField = 99,
/// Can't calculate hash of the payload fields
#[error("Can't calculate hash of the payload fields")]
InvalidTransactionCannotCalculateFieldsHash = 100,
/// Unexpected fields in payload
#[error("Unexpected fields in payload")]
InvalidTransactionUnexpectedFields = 101,
/// Expected bytes arguments
#[error("expected bytes arguments")]
InvalidTransactionExpectedBytesArguments = 102,
/// Missing seed field in transaction
#[error("Missing seed field in transaction")]
InvalidTransactionMissingSeed = 103,
/// Pricing mode not supported
#[error("Pricing mode not supported")]
PricingModeNotSupported = 104,
}

impl TryFrom<u16> for ErrorCode {
Expand Down Expand Up @@ -415,6 +436,13 @@ impl TryFrom<u16> for ErrorCode {
95 => Ok(ErrorCode::MalformedBinaryRequestHeader),
96 => Ok(ErrorCode::MalformedBinaryRequest),
97 => Ok(ErrorCode::InvalidTransactionNoWasmLaneMatches),
98 => Ok(ErrorCode::InvalidTransactionEntryPointMustBeCall),
99 => Ok(ErrorCode::InvalidTransactionCannotDeserializeField),
100 => Ok(ErrorCode::InvalidTransactionCannotCalculateFieldsHash),
101 => Ok(ErrorCode::InvalidTransactionUnexpectedFields),
102 => Ok(ErrorCode::InvalidTransactionExpectedBytesArguments),
103 => Ok(ErrorCode::InvalidTransactionMissingSeed),
104 => Ok(ErrorCode::PricingModeNotSupported),
_ => Err(UnknownErrorCode),
}
}
Expand Down Expand Up @@ -560,7 +588,23 @@ impl From<InvalidTransactionV1> for ErrorCode {
InvalidTransactionV1::NoWasmLaneMatchesTransaction() => {
ErrorCode::InvalidTransactionNoWasmLaneMatches
}
_other => ErrorCode::InvalidTransactionUnspecified,
InvalidTransactionV1::EntryPointMustBeCall { .. } => {
ErrorCode::InvalidTransactionEntryPointMustBeCall
}
InvalidTransactionV1::CouldNotDeserializeField { .. } => {
ErrorCode::InvalidTransactionCannotDeserializeField
}
InvalidTransactionV1::CannotCalculateFieldsHash => {
ErrorCode::InvalidTransactionCannotCalculateFieldsHash
}
InvalidTransactionV1::UnexpectedTransactionFieldEntries => {
ErrorCode::InvalidTransactionUnexpectedFields
}
InvalidTransactionV1::ExpectedBytesArguments => {
ErrorCode::InvalidTransactionExpectedBytesArguments
}
InvalidTransactionV1::MissingSeed => ErrorCode::InvalidTransactionMissingSeed,
InvalidTransactionV1::PricingModeNotSupported => ErrorCode::PricingModeNotSupported,
}
}
}
Expand Down

0 comments on commit 8d63ca2

Please sign in to comment.