From a703f071cfad830c28fb355ad4ba19ab4029f07b Mon Sep 17 00:00:00 2001 From: Cosmic Horror Date: Sat, 21 Jun 2025 21:28:55 -0600 Subject: [PATCH] refactor: replace `thiserror` with a manual impl --- Cargo.toml | 1 - src/error.rs | 25 +++++++++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 058b15d..71380f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,6 @@ tempfile = { version = "3", optional = true } zeroize = { version = "1.1.1", optional = true } fuzzy-matcher = { version = "0.3.7", optional = true } shell-words = "1.1.0" -thiserror = "1.0.40" [[example]] name = "password" diff --git a/src/error.rs b/src/error.rs index 6825500..c6e06ab 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,13 +1,26 @@ -use std::{io::Error as IoError, result::Result as StdResult}; - -use thiserror::Error; +use std::{fmt, io::Error as IoError, result::Result as StdResult}; /// Possible errors returned by prompts. -#[derive(Error, Debug)] +#[derive(Debug)] pub enum Error { /// Error while executing IO operations. - #[error("IO error: {0}")] - IO(#[from] IoError), + IO(IoError), +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::IO(io) => write!(f, "IO error: {}", io), + } + } +} + +impl std::error::Error for Error {} + +impl From for Error { + fn from(err: IoError) -> Self { + Self::IO(err) + } } /// Result type where errors are of type [Error](enum@Error).