Skip to main content

rustloclib/
error.rs

1//! Error types for rustloclib
2
3use std::path::PathBuf;
4use thiserror::Error;
5
6/// Errors that can occur during LOC counting
7#[derive(Error, Debug)]
8pub enum RustlocError {
9    /// Failed to read a file
10    #[error("failed to read file '{path}': {source}")]
11    FileRead {
12        path: PathBuf,
13        source: std::io::Error,
14    },
15
16    /// Failed to parse Cargo.toml or workspace metadata
17    #[error("failed to parse cargo metadata: {0}")]
18    CargoMetadata(String),
19
20    /// Invalid glob pattern
21    #[error("invalid glob pattern '{pattern}': {message}")]
22    InvalidGlob { pattern: String, message: String },
23
24    /// Path does not exist
25    #[error("path does not exist: {0}")]
26    PathNotFound(PathBuf),
27
28    /// Not a Rust file
29    #[error("not a Rust file: {0}")]
30    NotRustFile(PathBuf),
31
32    /// IO error
33    #[error("IO error: {0}")]
34    Io(#[from] std::io::Error),
35
36    /// Git operation error
37    #[error("git error: {0}")]
38    GitError(String),
39}