1use std::path::PathBuf;
9
10#[non_exhaustive]
16#[derive(Debug, Clone, thiserror::Error)]
17pub enum Error {
18 #[error("source '{source_name}' failed: {reason}. Fix: inspect the source implementation and input boundary for panics, stalls, or invalid reads.")]
20 SourceFailed {
21 source_name: String,
23 reason: String,
25 },
26
27 #[error("failed to read {path}: {reason}. Fix: verify the path exists and is readable.")]
29 ReadFailed {
30 path: PathBuf,
32 reason: String,
34 },
35
36 #[error("corrupt data in {path}: {reason}. Fix: repair or remove the malformed input.")]
38 CorruptData {
39 path: PathBuf,
41 reason: String,
43 },
44
45 #[error("no files matched pattern: {pattern}. Fix: point the source at at least one existing input file.")]
47 EmptySource {
48 pattern: String,
50 },
51
52 #[error("pipeline shut down")]
54 Shutdown,
55
56 #[error("transform failed on item {index}: {reason}. Fix: inspect the transform input and handle that case explicitly.")]
58 TransformFailed {
59 index: u64,
61 reason: String,
63 },
64
65 #[error("collation failed: {reason}. Fix: ensure each sample in the batch has the same required fields, dtype, and shape.")]
67 CollateFailed {
68 reason: String,
70 },
71
72 #[error("i/o error: {0}. Fix: resolve the underlying operating system error and retry.")]
74 Io(std::sync::Arc<std::io::Error>),
75
76 #[error("invalid glob pattern: {0}. Fix: provide a valid glob expression.")]
78 InvalidPattern(String),
79
80 #[error(
82 "invalid config: {reason}. Fix: update the pipeline configuration to a supported value."
83 )]
84 InvalidConfig {
85 reason: String,
87 },
88}
89
90impl From<std::io::Error> for Error {
91 fn from(e: std::io::Error) -> Self {
92 Error::Io(std::sync::Arc::new(e))
93 }
94}
95
96impl From<glob::PatternError> for Error {
97 fn from(e: glob::PatternError) -> Self {
98 Error::InvalidPattern(e.to_string())
99 }
100}
101
102pub type Result<T> = std::result::Result<T, Error>;