use reqwest::StatusCode;
#[derive(Debug, thiserror::Error)]
pub enum QuestradeError {
#[error("HTTP request failed: {0}")]
Http(#[from] reqwest::Error),
#[error("Questrade API error ({status}): {body}")]
Api {
status: StatusCode,
body: String,
},
#[error("Questrade API rate limit exceeded after {retries} retries")]
RateLimited {
retries: u32,
},
#[error("Token refresh failed ({status}): {body}")]
TokenRefresh {
status: StatusCode,
body: String,
},
#[error("Failed to parse response: {0}")]
Deserialization(#[from] serde_json::Error),
#[error("{context}: {source}")]
DateTime {
context: String,
source: Box<dyn std::error::Error + Send + Sync>,
},
#[error("Symbol not found: {0}")]
SymbolNotFound(String),
#[error("{0}")]
EmptyResponse(String),
}
pub type Result<T> = std::result::Result<T, QuestradeError>;