doctree_rust/doctree/src/error.rs
2025-05-13 08:52:47 +03:00

60 lines
1.4 KiB
Rust

use thiserror::Error;
/// Custom error type for the doctree library
#[derive(Error, Debug)]
pub enum DocTreeError {
/// IO error
#[error("IO error: {0}")]
IoError(#[from] std::io::Error),
/// WalkDir error
#[error("WalkDir error: {0}")]
WalkDirError(String),
/// Collection not found
#[error("Collection not found: {0}")]
CollectionNotFound(String),
/// Page not found
#[error("Page not found: {0}")]
PageNotFound(String),
/// File not found
#[error("File not found: {0}")]
FileNotFound(String),
/// Invalid include directive
#[error("Invalid include directive: {0}")]
InvalidIncludeDirective(String),
/// No default collection set
#[error("No default collection set")]
NoDefaultCollection,
/// Invalid number of arguments
#[error("Invalid number of arguments")]
InvalidArgumentCount,
/// Missing required parameter
#[error("Missing required parameter: {0}")]
MissingParameter(String),
/// Redis error
#[error("Redis error: {0}")]
RedisError(String),
/// CSV error
#[error("CSV error: {0}")]
CsvError(String),
/// IPFS error
#[error("IPFS error: {0}")]
IpfsError(String),
/// Encryption error
#[error("Encryption error: {0}")]
EncryptionError(String),
}
/// Result type alias for doctree operations
pub type Result<T> = std::result::Result<T, DocTreeError>;