use std::path::PathBuf;
#[non_exhaustive]
#[derive(Debug, Clone, thiserror::Error)]
pub enum Error {
#[error("source '{source_name}' failed: {reason}. Fix: inspect the source implementation and input boundary for panics, stalls, or invalid reads.")]
SourceFailed {
source_name: String,
reason: String,
},
#[error("failed to read {path}: {reason}. Fix: verify the path exists and is readable.")]
ReadFailed {
path: PathBuf,
reason: String,
},
#[error("corrupt data in {path}: {reason}. Fix: repair or remove the malformed input.")]
CorruptData {
path: PathBuf,
reason: String,
},
#[error("no files matched pattern: {pattern}. Fix: point the source at at least one existing input file.")]
EmptySource {
pattern: String,
},
#[error("pipeline shut down")]
Shutdown,
#[error("transform failed on item {index}: {reason}. Fix: inspect the transform input and handle that case explicitly.")]
TransformFailed {
index: u64,
reason: String,
},
#[error("collation failed: {reason}. Fix: ensure each sample in the batch has the same required fields, dtype, and shape.")]
CollateFailed {
reason: String,
},
#[error("i/o error: {0}. Fix: resolve the underlying operating system error and retry.")]
Io(std::sync::Arc<std::io::Error>),
#[error("invalid glob pattern: {0}. Fix: provide a valid glob expression.")]
InvalidPattern(String),
#[error(
"invalid config: {reason}. Fix: update the pipeline configuration to a supported value."
)]
InvalidConfig {
reason: String,
},
}
impl From<std::io::Error> for Error {
fn from(e: std::io::Error) -> Self {
Error::Io(std::sync::Arc::new(e))
}
}
impl From<glob::PatternError> for Error {
fn from(e: glob::PatternError) -> Self {
Error::InvalidPattern(e.to_string())
}
}
pub type Result<T> = std::result::Result<T, Error>;