use thiserror::Error;
#[derive(Error, Debug)]
pub enum ClobError {
#[error("HTTP request failed: {0}")]
HttpError(#[from] reqwest::Error),
#[error("JSON error: {0}")]
JsonError(#[from] serde_json::Error),
#[error("Signer is needed to interact with this endpoint")]
L1AuthUnavailable,
#[error("API Credentials are needed to interact with this endpoint")]
L2AuthNotAvailable,
#[error("Builder API Credentials needed to interact with this endpoint")]
BuilderAuthNotAvailable,
#[error("Builder key auth failed")]
BuilderAuthFailed,
#[error("Invalid price ({price}), min: {min} - max: {max}")]
InvalidPrice { price: f64, min: f64, max: f64 },
#[error("Invalid tick size ({tick_size}), minimum for the market is {min_tick_size}")]
InvalidTickSize {
tick_size: String,
min_tick_size: String,
},
#[error("No orderbook available")]
NoOrderbook,
#[error("No match found in orderbook")]
NoMatch,
#[error("Ethereum wallet error: {0}")]
WalletError(String),
#[error("EIP-712 signing error: {0}")]
SigningError(String),
#[error("Base64 decode error: {0}")]
Base64Error(#[from] base64::DecodeError),
#[error("Invalid configuration: {0}")]
ConfigError(String),
#[error("API error: {message}")]
ApiError { message: String, status: u16 },
#[error("{0}")]
Other(String),
}
pub type ClobResult<T> = Result<T, ClobError>;