Skip to main content

defillama_rs/
error.rs

1//! Error types for the DefiLlama API client
2
3use thiserror::Error;
4
5/// Error type for the DefiLlama API client
6#[derive(Error, Debug)]
7pub enum DefillamaError {
8    /// Error returned by reqwest
9    #[error("HTTP request error: {0}")]
10    RequestError(#[from] reqwest::Error),
11
12    /// URL parsing error
13    #[error("URL parsing error: {0}")]
14    UrlParseError(#[from] url::ParseError),
15
16    /// Error returned when the API returns an error message
17    #[error("API error: {0}")]
18    ApiError(String),
19
20    /// Error when parsing the API response
21    #[error("Failed to parse API response: {0}")]
22    ParseError(String),
23
24    /// Error when a required field is missing in the response
25    #[error("Missing field in API response: {0}")]
26    MissingField(String),
27
28    /// Any other error
29    #[error("Other error: {0}")]
30    Other(String),
31}