diff --git a/Cargo.toml b/Cargo.toml index d7cf32c..c69b83b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ categories = ["parser-implementations", "finance", "command-line-utilities"] [dependencies] # Core quick-xml = "0.36" -compact_str = "0.8" +compact_str = "0.7" chrono = "0.4" # Performance diff --git a/src/lib.rs b/src/lib.rs index b9e0289..98a1132 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -102,17 +102,29 @@ pub struct ValidationStats { pub type Result = std::result::Result; -#[derive(Debug, thiserror::Error)] +#[derive(Debug)] pub enum Error { - #[error("IO error: {0}")] - Io(#[from] std::io::Error), - - #[error("Parse error: {0}")] + Io(std::io::Error), Parse(String), - - #[error("Validation error: {0}")] Validation(String), - - #[error("Not found: {0}")] NotFound(String), } + +impl std::fmt::Display for Error { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Error::Io(e) => write!(f, "IO error: {}", e), + Error::Parse(s) => write!(f, "Parse error: {}", s), + Error::Validation(s) => write!(f, "Validation error: {}", s), + Error::NotFound(s) => write!(f, "Not found: {}", s), + } + } +} + +impl std::error::Error for Error {} + +impl From for Error { + fn from(err: std::io::Error) -> Self { + Error::Io(err) + } +}