beautiful_md/
error.rs

1//! Error types for beautiful-md.
2//!
3//! This module defines all error types used throughout the library,
4//! following Rust's error handling best practices.
5
6use std::path::PathBuf;
7
8/// Result type alias for this crate.
9pub type Result<T> = std::result::Result<T, Error>;
10
11/// The main error type for this crate.
12#[derive(Debug, thiserror::Error)]
13pub enum Error {
14    /// I/O error occurred while reading or writing files.
15    #[error("I/O error: {0}")]
16    Io(#[from] std::io::Error),
17
18    /// Failed to parse markdown.
19    #[error("Failed to parse markdown: {0}")]
20    ParseError(String),
21
22    /// Failed to load or parse configuration.
23    #[error("Configuration error: {0}")]
24    ConfigError(String),
25
26    /// File path is invalid or inaccessible.
27    #[error("Invalid file path: {}", .0.display())]
28    InvalidPath(PathBuf),
29
30    /// Pattern matching error for glob patterns.
31    #[error("Pattern error: {0}")]
32    PatternError(#[from] glob::PatternError),
33
34    /// Glob iteration error.
35    #[error("Glob error: {0}")]
36    GlobError(#[from] glob::GlobError),
37
38    /// TOML deserialization error.
39    #[error("TOML error: {0}")]
40    TomlError(#[from] toml::de::Error),
41
42    /// Custom error for formatting issues.
43    #[error("Formatting error: {0}")]
44    FormattingError(String),
45}