-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patherror.rs
More file actions
39 lines (35 loc) · 1.27 KB
/
error.rs
File metadata and controls
39 lines (35 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use signet_types::MarketError;
use std::fmt::Debug;
use trevm::{
revm::{primitives::EVMError, Database},
BundleError,
};
/// Errors that can occur when running a bundle on the Signet EVM.
#[derive(thiserror::Error)]
pub enum SignetBundleError<Db: Database> {
/// A primitive [`BundleError`] error ocurred.
#[error(transparent)]
BundleError(#[from] BundleError<Db>),
/// A [`MarketError`] ocurred.
#[error(transparent)]
MarketError(#[from] MarketError),
}
impl<Db: Database> Debug for SignetBundleError<Db> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
SignetBundleError::BundleError(e) => write!(f, "BundleError({:?})", e),
SignetBundleError::MarketError(e) => write!(f, "MarketError({:?})", e),
}
}
}
impl<Db: Database> From<EVMError<Db::Error>> for SignetBundleError<Db> {
fn from(e: EVMError<Db::Error>) -> Self {
SignetBundleError::BundleError(BundleError::EVMError { inner: e })
}
}
impl<Db: Database> SignetBundleError<Db> {
/// Instantiate a new [`SignetBundleError`] from a [`Database::Error`].
pub const fn evm_db(e: Db::Error) -> Self {
SignetBundleError::BundleError(BundleError::EVMError { inner: EVMError::Database(e) })
}
}