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("unknown error code {code}: {message}")]
23 Unknown { code: u8, message: String },
24}
25
26impl AddTransactionError {
27 pub fn from_code(code: u8, message: &str) -> Self {
28 match code {
29 0 => Self::Internal,
30 1 => Self::Expired,
31 2 => Self::StateConflict { message: String::from(message) },
32 3 => Self::CapacityExceeded,
33 _ => Self::Unknown { code, message: String::from(message) },
34 }
35 }
36}