fast_yaml_cli/batch/
error.rs

1//! Error types for batch file processing.
2
3use std::path::PathBuf;
4use thiserror::Error;
5
6/// Errors that can occur during file discovery.
7#[derive(Debug, Error)]
8pub enum DiscoveryError {
9    /// Invalid globset pattern (from include/exclude patterns)
10    #[error("invalid glob pattern '{pattern}': {source}")]
11    InvalidPattern {
12        /// The pattern that was invalid
13        pattern: String,
14        /// The underlying error
15        #[source]
16        source: globset::Error,
17    },
18
19    /// Invalid glob expansion pattern
20    #[error("invalid glob pattern '{pattern}': {source}")]
21    InvalidGlobPattern {
22        /// The pattern that was invalid
23        pattern: String,
24        /// The underlying error
25        #[source]
26        source: glob::PatternError,
27    },
28
29    /// IO error during directory traversal
30    #[error("failed to read '{path}': {source}")]
31    IoError {
32        /// The path that caused the error
33        path: PathBuf,
34        /// The underlying IO error
35        #[source]
36        source: std::io::Error,
37    },
38
39    /// Permission denied
40    #[error("permission denied: '{path}'")]
41    PermissionDenied {
42        /// The path where permission was denied
43        path: PathBuf,
44    },
45
46    /// Broken symbolic link
47    #[error("broken symbolic link: '{path}'")]
48    BrokenSymlink {
49        /// The path to the broken symlink
50        path: PathBuf,
51    },
52
53    /// Path does not exist
54    #[error("path does not exist: '{path}'")]
55    PathNotFound {
56        /// The path that was not found
57        path: PathBuf,
58    },
59
60    /// Error reading from stdin
61    #[error("failed to read file list from stdin: {source}")]
62    StdinError {
63        /// The underlying IO error
64        #[source]
65        source: std::io::Error,
66    },
67
68    /// Too many paths provided
69    #[error("exceeded maximum of {max} paths")]
70    TooManyPaths {
71        /// The maximum allowed
72        max: usize,
73    },
74}
75
76/// Errors that can occur during file processing.
77#[derive(Debug, Error)]
78#[allow(clippy::enum_variant_names)]
79pub enum ProcessingError {
80    /// Failed to read file
81    #[error("failed to read file: {0}")]
82    ReadError(#[source] std::io::Error),
83
84    /// File is not valid UTF-8
85    #[error("file is not valid UTF-8: {0}")]
86    Utf8Error(#[source] std::str::Utf8Error),
87
88    /// Failed to parse YAML
89    #[error("failed to parse YAML: {0}")]
90    ParseError(String),
91
92    /// Failed to format YAML
93    #[error("failed to format YAML: {0}")]
94    FormatError(String),
95
96    /// Failed to write file
97    #[error("failed to write file: {0}")]
98    WriteError(#[source] std::io::Error),
99
100    /// Failed to memory-map file
101    #[error("failed to memory-map file: {0}")]
102    MmapError(#[source] std::io::Error),
103}