Skip to main content

transferred_core/
error.rs

1use thiserror::Error;
2
3/// Root error type. Every fallible operation in `transferred` returns `Result<T, TransferredError>`.
4/// Maps to Python `transferred.TransferredError` at the FFI boundary.
5#[derive(Debug, Error)]
6pub enum TransferredError {
7    /// A source connector failed to read or produce data.
8    #[error("source error: {0}")]
9    Source(String),
10
11    /// Source produced zero batches (Python `EmptySourceError`).
12    #[error("empty source: produced no batches")]
13    EmptySource,
14
15    /// A destination connector failed to write or finalize output.
16    #[error("destination error: {0}")]
17    Destination(String),
18
19    /// Underlying I/O failure (filesystem, network).
20    #[error("io error: {0}")]
21    Io(#[from] std::io::Error),
22
23    /// Arrow compute or schema error surfaced from the data layer.
24    #[error("arrow error: {0}")]
25    Arrow(#[from] arrow::error::ArrowError),
26
27    /// Any error that does not fit the other variants.
28    #[error("{0}")]
29    Other(String),
30}
31
32impl TransferredError {
33    /// Construct a [`TransferredError::Source`] from any message.
34    pub fn source<S: Into<String>>(msg: S) -> Self {
35        Self::Source(msg.into())
36    }
37
38    /// Construct a [`TransferredError::Destination`] from any message.
39    pub fn destination<S: Into<String>>(msg: S) -> Self {
40        Self::Destination(msg.into())
41    }
42
43    /// Construct a [`TransferredError::Other`] from any message.
44    pub fn other<S: Into<String>>(msg: S) -> Self {
45        Self::Other(msg.into())
46    }
47}