Skip to main content

tradestation_api/
error.rs

1//! Error types for the TradeStation API client.
2
3/// Errors returned by the TradeStation API client.
4#[derive(Debug, thiserror::Error)]
5pub enum Error {
6    /// An HTTP transport error (connection, timeout, TLS).
7    #[error("HTTP request failed: {0}")]
8    Http(#[from] reqwest::Error),
9
10    /// Failed to parse a JSON response body.
11    #[error("JSON parsing failed: {0}")]
12    Json(#[from] serde_json::Error),
13
14    /// Authentication or token management error.
15    #[error("Authentication failed: {0}")]
16    Auth(String),
17
18    /// The API returned a non-success HTTP status code.
19    #[error("API error ({status}): {message}")]
20    Api {
21        /// HTTP status code.
22        status: u16,
23        /// Response body or error message.
24        message: String,
25    },
26
27    /// The streaming connection was closed by the server.
28    #[error("Stream ended: {0}")]
29    StreamEnded(String),
30}