Skip to main content

digdigdig3_station/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum StationError {
5    #[error("station not yet built")]
6    NotBuilt,
7    #[error("subscription failed: {0}")]
8    Subscribe(String),
9    /// The exchange does not expose this stream on the WS wire. Subscribe
10    /// MUST NOT spawn a forwarder for this combination — heal/resub would
11    /// loop forever. Surfaced from `subscribe_frame` returning either
12    /// `WebSocketError::NotSupported` or `WebSocketError::UnsupportedOperation`.
13    /// Consumers should treat this as a quiet "skip" rather than a hard
14    /// failure: it's an architectural fact about the venue, not a runtime fault.
15    #[error("stream not supported by exchange: {0}")]
16    StreamNotSupported(String),
17    #[error("core error: {0}")]
18    Core(String),
19    #[error("io error: {0}")]
20    Io(#[from] std::io::Error),
21}
22
23impl StationError {
24    /// True when this error originates from the venue not exposing the
25    /// requested stream (wire-not-present), as opposed to a transient
26    /// runtime failure. Used by `Station::subscribe(set)` to bucket
27    /// per-stream outcomes in the returned `SubscribeReport`.
28    pub fn is_not_supported(&self) -> bool {
29        matches!(self, StationError::StreamNotSupported(_))
30    }
31}
32
33pub type Result<T> = std::result::Result<T, StationError>;