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 { code: String, message: String },
13
14    /// Rate limit exceeded
15    #[error("Rate limit exceeded")]
16    RateLimitExceeded,
17
18    /// Network error
19    #[error("Network error: {0}")]
20    NetworkError(#[from] reqwest::Error),
21
22    /// Invalid request
23    #[error("Invalid request: {0}")]
24    InvalidRequest(String),
25
26    /// Serialization error
27    #[error("Serialization error: {0}")]
28    SerializationError(#[from] serde_json::Error),
29
30    /// MFA required
31    #[error("MFA required")]
32    MfaRequired,
33
34    /// Unauthorized
35    #[error("Unauthorized")]
36    Unauthorized,
37
38    /// Unknown error
39    #[error("Unknown error: {0}")]
40    Unknown(String),
41}
42
43/// Result type for Webull API operations
44pub type WebullResult<T> = Result<T, WebullError>;