diff --git a/Cargo.lock b/Cargo.lock index 7015103cc..0d6d00cb5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3032,6 +3032,7 @@ name = "uu_numfmt" version = "0.0.30" dependencies = [ "clap", + "thiserror 2.0.12", "uucore", ] diff --git a/src/uu/numfmt/Cargo.toml b/src/uu/numfmt/Cargo.toml index e0d285907..0bad48915 100644 --- a/src/uu/numfmt/Cargo.toml +++ b/src/uu/numfmt/Cargo.toml @@ -19,6 +19,7 @@ path = "src/numfmt.rs" [dependencies] clap = { workspace = true } uucore = { workspace = true, features = ["ranges"] } +thiserror = { workspace = true } [[bin]] name = "numfmt" diff --git a/src/uu/numfmt/src/errors.rs b/src/uu/numfmt/src/errors.rs index 77dd6f0aa..d3dcc4873 100644 --- a/src/uu/numfmt/src/errors.rs +++ b/src/uu/numfmt/src/errors.rs @@ -3,13 +3,12 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -use std::{ - error::Error, - fmt::{Debug, Display}, -}; +use std::fmt::Debug; +use thiserror::Error; use uucore::error::UError; -#[derive(Debug)] +#[derive(Debug, Error)] +#[error("{0}")] pub enum NumfmtError { IoError(String), IllegalArgument(String), @@ -25,15 +24,3 @@ impl UError for NumfmtError { } } } - -impl Error for NumfmtError {} - -impl Display for NumfmtError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::IoError(s) | Self::IllegalArgument(s) | Self::FormattingError(s) => { - write!(f, "{s}") - } - } - } -}