mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
numfmt: move to thiserror
This commit is contained in:
parent
4f1d33fec3
commit
e20500d1e5
3 changed files with 6 additions and 17 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -3032,6 +3032,7 @@ name = "uu_numfmt"
|
||||||
version = "0.0.30"
|
version = "0.0.30"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
|
"thiserror 2.0.12",
|
||||||
"uucore",
|
"uucore",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ path = "src/numfmt.rs"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { workspace = true }
|
clap = { workspace = true }
|
||||||
uucore = { workspace = true, features = ["ranges"] }
|
uucore = { workspace = true, features = ["ranges"] }
|
||||||
|
thiserror = { workspace = true }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "numfmt"
|
name = "numfmt"
|
||||||
|
|
|
@ -3,13 +3,12 @@
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
|
|
||||||
use std::{
|
use std::fmt::Debug;
|
||||||
error::Error,
|
use thiserror::Error;
|
||||||
fmt::{Debug, Display},
|
|
||||||
};
|
|
||||||
use uucore::error::UError;
|
use uucore::error::UError;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Error)]
|
||||||
|
#[error("{0}")]
|
||||||
pub enum NumfmtError {
|
pub enum NumfmtError {
|
||||||
IoError(String),
|
IoError(String),
|
||||||
IllegalArgument(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}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue