miden_client/rpc/errors/node/
transaction.rs1use alloc::string::String;
2
3use thiserror::Error;
4
5#[derive(Debug, Clone, PartialEq, Eq, Error)]
7pub enum AddTransactionError {
8 #[error("internal server error")]
10 Internal,
11 #[error("input notes already consumed")]
13 InputNotesAlreadyConsumed,
14 #[error("unauthenticated notes not found")]
16 UnauthenticatedNotesNotFound,
17 #[error("output notes already exist")]
19 OutputNotesAlreadyExist,
20 #[error("incorrect account initial commitment")]
22 IncorrectAccountInitialCommitment,
23 #[error("invalid transaction proof")]
25 InvalidTransactionProof,
26 #[error("failed to deserialize transaction")]
28 TransactionDeserializationFailed,
29 #[error("transaction expired")]
31 Expired,
32 #[error("block producer capacity exceeded")]
34 CapacityExceeded,
35 #[error("unknown error code {code}: {message}")]
38 Unknown { code: u8, message: String },
39}
40
41impl AddTransactionError {
42 pub fn from_code(code: u8, message: &str) -> Self {
43 match code {
44 0 => Self::Internal,
45 1 => Self::InputNotesAlreadyConsumed,
46 2 => Self::UnauthenticatedNotesNotFound,
47 3 => Self::OutputNotesAlreadyExist,
48 4 => Self::IncorrectAccountInitialCommitment,
49 5 => Self::InvalidTransactionProof,
50 6 => Self::TransactionDeserializationFailed,
51 7 => Self::Expired,
52 8 => Self::CapacityExceeded,
53 _ => Self::Unknown { code, message: String::from(message) },
54 }
55 }
56}