morpho_rs_api/
error.rs

1//! Error types for the Morpho API client.
2
3use thiserror::Error;
4
5/// Errors that can occur when using the Morpho API client.
6#[derive(Debug, Error)]
7pub enum ApiError {
8    /// HTTP request failed.
9    #[error("HTTP request failed: {0}")]
10    Request(#[from] reqwest::Error),
11
12    /// GraphQL query returned errors.
13    #[error("GraphQL error: {0}")]
14    GraphQL(String),
15
16    /// Failed to parse response.
17    #[error("Failed to parse response: {0}")]
18    Parse(String),
19
20    /// Vault not found.
21    #[error("Vault not found: {address} on chain {chain_id}")]
22    VaultNotFound { address: String, chain_id: i64 },
23
24    /// Invalid address format.
25    #[error("Invalid address format: {0}")]
26    InvalidAddress(String),
27
28    /// Invalid chain ID.
29    #[error("Invalid chain ID: {0}")]
30    InvalidChainId(i64),
31
32    /// Contract error.
33    #[error("Contract error: {0}")]
34    Contract(#[from] morpho_rs_contracts::ContractError),
35
36    /// Transaction support not configured.
37    #[error("Transaction support not configured: RPC URL and private key required")]
38    TransactionNotConfigured,
39}
40
41/// Result type alias for API operations.
42pub type Result<T> = std::result::Result<T, ApiError>;