1use thiserror::Error;
2
3#[derive(Error, Debug)]
5pub enum ClobError {
6 #[error("HTTP request failed: {0}")]
8 HttpError(#[from] reqwest::Error),
9
10 #[error("JSON error: {0}")]
12 JsonError(#[from] serde_json::Error),
13
14 #[error("Signer is needed to interact with this endpoint")]
16 L1AuthUnavailable,
17
18 #[error("API Credentials are needed to interact with this endpoint")]
20 L2AuthNotAvailable,
21
22 #[error("Builder API Credentials needed to interact with this endpoint")]
24 BuilderAuthNotAvailable,
25
26 #[error("Builder key auth failed")]
28 BuilderAuthFailed,
29
30 #[error("Invalid price ({price}), min: {min} - max: {max}")]
32 InvalidPrice { price: f64, min: f64, max: f64 },
33
34 #[error("Invalid tick size ({tick_size}), minimum for the market is {min_tick_size}")]
36 InvalidTickSize {
37 tick_size: String,
38 min_tick_size: String,
39 },
40
41 #[error("Invalid user provided fee rate: {user_fee_rate}, fee rate for the market must be {market_fee_rate}")]
43 InvalidFeeRate {
44 user_fee_rate: u32,
45 market_fee_rate: u32,
46 },
47
48 #[error("No orderbook available")]
50 NoOrderbook,
51
52 #[error("No match found in orderbook")]
54 NoMatch,
55
56 #[error("Ethereum wallet error: {0}")]
58 WalletError(String),
59
60 #[error("EIP-712 signing error: {0}")]
62 SigningError(String),
63
64 #[error("Base64 decode error: {0}")]
66 Base64Error(#[from] base64::DecodeError),
67
68 #[error("Invalid configuration: {0}")]
70 ConfigError(String),
71
72 #[error("API error: {message}")]
74 ApiError { message: String, status: u16 },
75
76 #[error("{0}")]
78 Other(String),
79}
80
81pub type ClobResult<T> = Result<T, ClobError>;