Skip to main content

oxigeo_streaming/
error.rs

1//! Error types for the streaming module.
2
3#[cfg(not(feature = "std"))]
4use alloc::string::String;
5
6/// Result type for streaming operations.
7pub type Result<T> = core::result::Result<T, StreamingError>;
8
9/// Errors that can occur during streaming operations.
10#[derive(Debug, thiserror::Error)]
11pub enum StreamingError {
12    /// Core OxiGeo error
13    #[cfg(feature = "std")]
14    #[error("OxiGeo error: {0}")]
15    Core(#[from] oxigeo_core::error::OxiGeoError),
16
17    /// Stream is closed
18    #[error("Stream is closed")]
19    StreamClosed,
20
21    /// Stream buffer full
22    #[error("Stream buffer is full")]
23    BufferFull,
24
25    /// Invalid window configuration
26    #[error("Invalid window configuration: {0}")]
27    InvalidWindow(String),
28
29    /// Watermark error
30    #[error("Watermark error: {0}")]
31    WatermarkError(String),
32
33    /// State error
34    #[error("State error: {0}")]
35    StateError(String),
36
37    /// Checkpoint error
38    #[error("Checkpoint error: {0}")]
39    CheckpointError(String),
40
41    /// Partition error
42    #[error("Partition error: {0}")]
43    PartitionError(String),
44
45    /// Join error
46    #[error("Join error: {0}")]
47    JoinError(String),
48
49    /// Serialization error
50    #[error("Serialization error: {0}")]
51    SerializationError(String),
52
53    /// Deserialization error
54    #[error("Deserialization error: {0}")]
55    DeserializationError(String),
56
57    /// OxiStore key-value backend error
58    #[cfg(feature = "kv-store")]
59    #[error("KV store error: {0}")]
60    Store(#[from] oxistore_core::StoreError),
61
62    /// IO error
63    #[cfg(feature = "std")]
64    #[error("IO error: {0}")]
65    Io(#[from] std::io::Error),
66
67    /// Arrow error
68    #[cfg(feature = "std")]
69    #[error("Arrow error: {0}")]
70    Arrow(#[from] arrow::error::ArrowError),
71
72    /// Send error
73    #[error("Channel send error")]
74    SendError,
75
76    /// Receive error
77    #[error("Channel receive error")]
78    RecvError,
79
80    /// Timeout error
81    #[error("Operation timed out")]
82    Timeout,
83
84    /// Invalid state
85    #[error("Invalid state: {0}")]
86    InvalidState(String),
87
88    /// Configuration error
89    #[error("Configuration error: {0}")]
90    ConfigError(String),
91
92    /// Invalid operation
93    #[error("Invalid operation: {0}")]
94    InvalidOperation(String),
95
96    /// Not implemented
97    #[error("Not implemented: {0}")]
98    NotImplemented(String),
99
100    /// A required optional feature was not enabled at build time.
101    ///
102    /// Returned instead of fabricating a fake success (e.g. an empty tile body)
103    /// when a code path genuinely requires a Cargo feature that is turned off.
104    #[error("feature '{0}' is not enabled; rebuild with that feature to use this operation")]
105    FeatureNotEnabled(String),
106
107    /// Tile not found (HTTP 404 or equivalent)
108    #[error("Tile not found")]
109    TileNotFound,
110
111    /// HTTP error from tile fetch
112    #[cfg(feature = "tile-http")]
113    #[error("HTTP error: status {status}, url: {url}")]
114    HttpError {
115        /// HTTP status code
116        status: u16,
117        /// The URL that returned the error
118        url: String,
119    },
120
121    /// Reqwest (HTTP client) error
122    #[cfg(feature = "tile-http")]
123    #[error("HTTP client error: {0}")]
124    Reqwest(#[from] reqwest::Error),
125
126    /// Finalize called with fewer chunks than the preset total
127    #[error("Incomplete finalize: expected {expected} chunks, wrote {actual}")]
128    IncompleteFinalize {
129        /// The preset expected chunk count
130        expected: usize,
131        /// The number of chunks actually written
132        actual: usize,
133    },
134
135    /// Other error
136    #[error("Other error: {0}")]
137    Other(String),
138}
139
140#[cfg(feature = "std")]
141impl<T> From<crossbeam_channel::SendError<T>> for StreamingError {
142    fn from(_: crossbeam_channel::SendError<T>) -> Self {
143        StreamingError::SendError
144    }
145}
146
147#[cfg(feature = "std")]
148impl From<crossbeam_channel::RecvError> for StreamingError {
149    fn from(_: crossbeam_channel::RecvError) -> Self {
150        StreamingError::RecvError
151    }
152}
153
154#[cfg(feature = "std")]
155impl From<serde_json::Error> for StreamingError {
156    fn from(e: serde_json::Error) -> Self {
157        StreamingError::SerializationError(e.to_string())
158    }
159}