oxidized_builder/common/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum AppError {
5    #[error("Configuration error: {0}")]
6    Config(String),
7
8    #[error("Initialization failed: {0}")]
9    Initialization(String),
10
11    #[error("Connection failed to endpoint: {0}")]
12    Connection(String),
13
14    #[error("Transaction failed: {hash:?}, reason: {reason}")]
15    Transaction { hash: String, reason: String },
16
17    #[error("Strategy execution error: {0}")]
18    Strategy(String),
19
20    #[error("Insufficient funds. Required: {required}, Available: {available}")]
21    InsufficientFunds { required: String, available: String },
22
23    #[error("External API error: {provider} responded with {status}")]
24    ApiCall { provider: String, status: u16 },
25
26    #[error("Validation failed for field {field}: {message}")]
27    Validation { field: String, message: String },
28
29    #[error("Address {0} is invalid or not checksummed")]
30    InvalidAddress(String),
31
32    #[error(transparent)]
33    Unknown(#[from] anyhow::Error),
34}
35
36impl From<config::ConfigError> for AppError {
37    fn from(err: config::ConfigError) -> Self {
38        AppError::Config(err.to_string())
39    }
40}