Skip to content

Commit e20500d

Browse files
sgvictorinosylvestre
authored andcommitted
numfmt: move to thiserror
1 parent 4f1d33f commit e20500d

File tree

3 files changed

+6
-17
lines changed

3 files changed

+6
-17
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/uu/numfmt/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ path = "src/numfmt.rs"
1919
[dependencies]
2020
clap = { workspace = true }
2121
uucore = { workspace = true, features = ["ranges"] }
22+
thiserror = { workspace = true }
2223

2324
[[bin]]
2425
name = "numfmt"

src/uu/numfmt/src/errors.rs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
55

6-
use std::{
7-
error::Error,
8-
fmt::{Debug, Display},
9-
};
6+
use std::fmt::Debug;
7+
use thiserror::Error;
108
use uucore::error::UError;
119

12-
#[derive(Debug)]
10+
#[derive(Debug, Error)]
11+
#[error("{0}")]
1312
pub enum NumfmtError {
1413
IoError(String),
1514
IllegalArgument(String),
@@ -25,15 +24,3 @@ impl UError for NumfmtError {
2524
}
2625
}
2726
}
28-
29-
impl Error for NumfmtError {}
30-
31-
impl Display for NumfmtError {
32-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
33-
match self {
34-
Self::IoError(s) | Self::IllegalArgument(s) | Self::FormattingError(s) => {
35-
write!(f, "{s}")
36-
}
37-
}
38-
}
39-
}

0 commit comments

Comments
 (0)