Skip to main content

oxigdal_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 OxiGDAL error
13    #[cfg(feature = "std")]
14    #[error("OxiGDAL error: {0}")]
15    Core(#[from] oxigdal_core::error::OxiGdalError),
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    /// Tile not found (HTTP 404 or equivalent)
101    #[error("Tile not found")]
102    TileNotFound,
103
104    /// HTTP error from tile fetch
105    #[cfg(feature = "tile-http")]
106    #[error("HTTP error: status {status}, url: {url}")]
107    HttpError {
108        /// HTTP status code
109        status: u16,
110        /// The URL that returned the error
111        url: String,
112    },
113
114    /// Reqwest (HTTP client) error
115    #[cfg(feature = "tile-http")]
116    #[error("HTTP client error: {0}")]
117    Reqwest(#[from] reqwest::Error),
118
119    /// Finalize called with fewer chunks than the preset total
120    #[error("Incomplete finalize: expected {expected} chunks, wrote {actual}")]
121    IncompleteFinalize {
122        /// The preset expected chunk count
123        expected: usize,
124        /// The number of chunks actually written
125        actual: usize,
126    },
127
128    /// Other error
129    #[error("Other error: {0}")]
130    Other(String),
131}
132
133#[cfg(feature = "std")]
134impl<T> From<crossbeam_channel::SendError<T>> for StreamingError {
135    fn from(_: crossbeam_channel::SendError<T>) -> Self {
136        StreamingError::SendError
137    }
138}
139
140#[cfg(feature = "std")]
141impl From<crossbeam_channel::RecvError> for StreamingError {
142    fn from(_: crossbeam_channel::RecvError) -> Self {
143        StreamingError::RecvError
144    }
145}
146
147#[cfg(feature = "std")]
148impl From<serde_json::Error> for StreamingError {
149    fn from(e: serde_json::Error) -> Self {
150        StreamingError::SerializationError(e.to_string())
151    }
152}