drm_exchange_limitless/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum LimitlessError {
5    #[error("http error: {0}")]
6    Http(#[from] reqwest::Error),
7
8    #[error("api error: {0}")]
9    Api(String),
10
11    #[error("rate limited")]
12    RateLimited,
13
14    #[error("authentication required")]
15    AuthRequired,
16
17    #[error("authentication error: {0}")]
18    Auth(String),
19
20    #[error("market not found: {0}")]
21    MarketNotFound(String),
22
23    #[error("invalid order: {0}")]
24    InvalidOrder(String),
25}
26
27impl From<LimitlessError> for drm_core::ExchangeError {
28    fn from(err: LimitlessError) -> Self {
29        match err {
30            LimitlessError::MarketNotFound(id) => drm_core::ExchangeError::MarketNotFound(id),
31            LimitlessError::AuthRequired => {
32                drm_core::ExchangeError::Authentication("authentication required".into())
33            }
34            LimitlessError::Auth(msg) => drm_core::ExchangeError::Authentication(msg),
35            LimitlessError::InvalidOrder(msg) => drm_core::ExchangeError::InvalidOrder(msg),
36            other => drm_core::ExchangeError::Api(other.to_string()),
37        }
38    }
39}