1use std::sync::{PoisonError, RwLockWriteGuard};
5
6use crossbeam_channel::{RecvError, SendError};
8use ethers::{
9 providers::{MiddlewareError, ProviderError},
10 signers::WalletError,
11};
12use revm_primitives::{EVMError, HaltReason};
13use thiserror::Error;
14
15use self::environment::instruction::{Instruction, Outcome};
16use super::*;
17
18#[derive(Error, Debug)]
20pub enum ArbiterCoreError {
21 #[error("Account already exists!")]
23 AccountCreationError,
24
25 #[error("Account doesn't exist!")]
27 AccountDoesNotExistError,
28
29 #[error("Can't sign with a forked EOA!")]
31 ForkedEOASignError,
32
33 #[error("Failed to upgrade sender to a strong reference!")]
35 UpgradeSenderError,
36
37 #[error("Data missing when calling a transaction!")]
39 MissingDataError,
40
41 #[error("Invalid data used for a query request!")]
43 InvalidQueryError,
44
45 #[error("Failed to join environment thread on stop!")]
47 JoinError,
48
49 #[error("Execution failed with revert: {gas_used:?} gas used, {output:?}")]
51 ExecutionRevert {
52 gas_used: u64,
54 output: Vec<u8>,
56 },
57
58 #[error("Execution failed with halt: {reason:?}, {gas_used:?} gas used")]
60 ExecutionHalt {
61 reason: HaltReason,
63 gas_used: u64,
65 },
66
67 #[error(transparent)]
69 ParseIntError(#[from] std::num::ParseIntError),
70
71 #[error(transparent)]
73 EVMError(#[from] EVMError<Infallible>),
74
75 #[error(transparent)]
77 ProviderError(#[from] ProviderError),
78
79 #[error(transparent)]
81 WalletError(#[from] WalletError),
82
83 #[error(transparent)]
85 SendError(
86 #[from]
87 #[allow(private_interfaces)]
88 SendError<Instruction>,
89 ),
90
91 #[error(transparent)]
93 RecvError(#[from] RecvError),
94
95 #[error(transparent)]
97 FromStrRadixError(#[from] uint::FromStrRadixErr),
98
99 #[error(transparent)]
101 SerdeJsonError(#[from] serde_json::Error),
102
103 #[error("{0}")]
105 ReplyError(String),
106
107 #[error("{0}")]
109 RwLockError(String),
110}
111
112impl From<SendError<Result<Outcome, ArbiterCoreError>>> for ArbiterCoreError {
113 fn from(e: SendError<Result<Outcome, ArbiterCoreError>>) -> Self {
114 ArbiterCoreError::ReplyError(e.to_string())
115 }
116}
117
118impl<T> From<PoisonError<RwLockWriteGuard<'_, T>>> for ArbiterCoreError {
119 fn from(e: PoisonError<RwLockWriteGuard<'_, T>>) -> Self {
120 ArbiterCoreError::RwLockError(e.to_string())
121 }
122}
123
124impl MiddlewareError for ArbiterCoreError {
125 type Inner = ProviderError;
126
127 fn from_err(e: Self::Inner) -> Self {
128 ArbiterCoreError::from(e)
129 }
130
131 fn as_inner(&self) -> Option<&Self::Inner> {
132 None
133 }
134}