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("transaction expired")]
13 Expired,
14 #[error("transaction conflicts with current state: {message}")]
16 StateConflict { message: String },
17 #[error("the mempool is at capacity")]
19 CapacityExceeded,
20 #[error("transaction does not contain a canonical fee output note")]
22 MissingFee,
23 #[error("transaction consumes in-flight fee notes")]
25 ConsumesInflightFeeNotes,
26 #[error("transaction fee output note must use only the native asset")]
28 InvalidFeeAsset,
29 #[error("batch proof ID does not match the batch ID")]
31 BatchIdMismatch,
32 #[error("failed to authenticate transaction: {message}")]
34 AuthenticationFailed { message: String },
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::Expired,
46 2 => Self::StateConflict { message: String::from(message) },
47 3 => Self::CapacityExceeded,
48 4 => Self::MissingFee,
49 5 => Self::ConsumesInflightFeeNotes,
50 6 => Self::InvalidFeeAsset,
51 7 => Self::BatchIdMismatch,
52 8 => Self::AuthenticationFailed { message: String::from(message) },
53 _ => Self::Unknown { code, message: String::from(message) },
54 }
55 }
56}