signet_bundle/send/
error.rs1#[cfg(doc)]
2use crate::SignetEthBundle;
3use alloy::eips::eip2718::Eip2718Error;
4use signet_types::{MarketError, SignedPermitError};
5use trevm::{
6 revm::{context::result::EVMError, Database},
7 BundleError,
8};
9
10#[derive(Debug, thiserror::Error)]
13pub enum RecoverError {
14 #[error("Bundle must contain at least one RU transaction")]
16 EmptyBundle,
17
18 #[error(transparent)]
20 Decoding(#[from] Eip2718Error),
21
22 #[error(transparent)]
24 Recovering(#[from] alloy::consensus::crypto::RecoveryError),
25}
26
27#[derive(Debug, thiserror::Error)]
30#[error("Failed to decode transaction. Host: {host}, Index: {index}, Error: {inner}")]
31pub struct BundleRecoverError {
32 #[source]
34 pub inner: RecoverError,
35 pub host: bool,
37 pub index: usize,
39}
40
41impl BundleRecoverError {
42 pub fn new(inner: impl Into<RecoverError>, host: bool, index: usize) -> Self {
44 Self { inner: inner.into(), host, index }
45 }
46}
47
48#[derive(thiserror::Error)]
50pub enum SignetEthBundleError<Db: Database> {
51 #[error(transparent)]
53 Bundle(#[from] BundleError<Db>),
54
55 #[error(transparent)]
57 SignetPermit(#[from] SignedPermitError),
58
59 #[error(transparent)]
61 Contract(#[from] alloy::contract::Error),
62
63 #[error(transparent)]
65 Market(#[from] MarketError),
66
67 #[error("{0}")]
69 HostSimulation(&'static str),
70}
71
72impl<Db: Database> core::fmt::Debug for SignetEthBundleError<Db> {
73 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
74 match self {
75 SignetEthBundleError::Bundle(inner) => {
76 f.debug_tuple("BundleError").field(inner).finish()
77 }
78 SignetEthBundleError::SignetPermit(inner) => {
79 f.debug_tuple("SignedPermitError").field(inner).finish()
80 }
81 SignetEthBundleError::Contract(inner) => {
82 f.debug_tuple("ContractError").field(inner).finish()
83 }
84 SignetEthBundleError::Market(inner) => {
85 f.debug_tuple("MarketError").field(inner).finish()
86 }
87 SignetEthBundleError::HostSimulation(msg) => {
88 f.debug_tuple("HostSimulationError").field(msg).finish()
89 }
90 }
91 }
92}
93
94impl<Db: Database> From<EVMError<Db::Error>> for SignetEthBundleError<Db> {
95 fn from(err: EVMError<Db::Error>) -> Self {
96 Self::Bundle(BundleError::from(err))
97 }
98}