webull_rs/
error.rs

1use thiserror::Error;
2
3/// Errors that can occur when interacting with the Webull API.
4#[derive(Debug, Error)]
5pub enum WebullError {
6    /// Authentication error
7    #[error("Authentication error: {0}")]
8    AuthenticationError(String),
9    
10    /// API error with code and message
11    #[error("API error: {code} - {message}")]
12    ApiError { 
13        code: String, 
14        message: String 
15    },
16    
17    /// Rate limit exceeded
18    #[error("Rate limit exceeded")]
19    RateLimitExceeded,
20    
21    /// Network error
22    #[error("Network error: {0}")]
23    NetworkError(#[from] reqwest::Error),
24    
25    /// Invalid request
26    #[error("Invalid request: {0}")]
27    InvalidRequest(String),
28    
29    /// Serialization error
30    #[error("Serialization error: {0}")]
31    SerializationError(#[from] serde_json::Error),
32    
33    /// MFA required
34    #[error("MFA required")]
35    MfaRequired,
36    
37    /// Unauthorized
38    #[error("Unauthorized")]
39    Unauthorized,
40    
41    /// Unknown error
42    #[error("Unknown error: {0}")]
43    Unknown(String),
44}
45
46/// Result type for Webull API operations
47pub type WebullResult<T> = Result<T, WebullError>;