use std::io; use std::path::PathBuf; use thiserror::Error; /// Result type for WebBuilder operations pub type Result = std::result::Result; /// Error type for WebBuilder operations #[derive(Error, Debug)] pub enum WebBuilderError { /// IO error #[error("IO error: {0}")] IoError(#[from] io::Error), /// DocTree error #[error("DocTree error: {0}")] DocTreeError(#[from] doctree::DocTreeError), /// Hjson parsing error #[error("Hjson parsing error: {0}")] HjsonError(String), /// Git error #[error("Git error: {0}")] GitError(String), /// IPFS error #[error("IPFS error: {0}")] IpfsError(String), /// Missing file error #[error("Missing file: {0}")] MissingFile(PathBuf), /// Missing directory error #[error("Missing directory: {0}")] MissingDirectory(PathBuf), /// Missing configuration error #[error("Missing configuration: {0}")] MissingConfiguration(String), /// Invalid configuration error #[error("Invalid configuration: {0}")] InvalidConfiguration(String), /// Other error #[error("Error: {0}")] Other(String), } impl From for WebBuilderError { fn from(error: String) -> Self { WebBuilderError::Other(error) } } impl From<&str> for WebBuilderError { fn from(error: &str) -> Self { WebBuilderError::Other(error.to_string()) } } impl From for WebBuilderError { fn from(error: serde_json::Error) -> Self { WebBuilderError::Other(format!("JSON error: {}", error)) } }