Skip to main content

nexus_sdk/
error.rs

1//! Error types for Nexus SDK
2
3use thiserror::Error;
4
5/// Result type alias for Nexus SDK operations
6pub type Result<T> = std::result::Result<T, NexusError>;
7
8/// Errors that can occur when using the Nexus SDK
9#[derive(Debug, Error)]
10pub enum NexusError {
11    /// HTTP request error
12    #[error("HTTP error: {0}")]
13    Http(#[from] reqwest::Error),
14
15    /// JSON serialization/deserialization error
16    #[error("JSON error: {0}")]
17    Json(#[from] serde_json::Error),
18
19    /// Invalid URL
20    #[error("Invalid URL: {0}")]
21    Url(#[from] url::ParseError),
22
23    /// API error response
24    #[error("API error: {message} (status: {status})")]
25    Api {
26        /// Error message from API
27        message: String,
28        /// HTTP status code
29        status: u16,
30    },
31
32    /// Authentication error
33    #[error("Authentication failed: {0}")]
34    Authentication(String),
35
36    /// Invalid configuration
37    #[error("Invalid configuration: {0}")]
38    Configuration(String),
39
40    /// Connection error
41    #[error("Connection error: {0}")]
42    Connection(String),
43
44    /// Network error
45    #[error("Network error: {0}")]
46    Network(String),
47
48    /// Timeout error
49    #[error("Request timeout")]
50    Timeout,
51
52    /// Invalid response format
53    #[error("Invalid response format: {0}")]
54    InvalidResponse(String),
55
56    /// Validation error
57    #[error("Validation error: {0}")]
58    Validation(String),
59}