Skip to content

Commit e3a6016

Browse files
committed
Replace error-chain witch thiserror
1 parent 4527f7b commit e3a6016

File tree

3 files changed

+38
-27
lines changed

3 files changed

+38
-27
lines changed

Cargo.lock

Lines changed: 21 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ Rust applications or any other applications.
1818

1919
[dependencies]
2020
clap = { version = "4.5.48", features = ["derive"] }
21-
error-chain = "0.12"
2221
sysfs_gpio = "0.6.2"
2322
toml = { version = "<=0.9.6", default-features = false, features = ["parse", "serde"] }
2423
glob = "0.3.3"
@@ -36,6 +35,7 @@ backtrace = "=0.3.74"
3635
serde_spanned = "<=1.0.1"
3736
toml_datetime = "<=0.7.1"
3837
toml_parser = "<=1.0.2"
38+
thiserror = { version = "2.0.16", default-features = false }
3939

4040

4141
[[bin]]

src/error.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,26 @@
66
// option. This file may not be copied, modified, or distributed
77
// except according to those terms.
88

9-
use error_chain::error_chain;
109
use nix::Error as NixError;
1110
use std::io::Error as IoError;
1211
use sysfs_gpio::Error as GpioError;
1312

14-
error_chain! {
15-
types {
16-
Error, ErrorKind, ResultExt, Result;
17-
}
13+
#[derive(thiserror::Error, Debug)]
14+
pub enum Error {
15+
#[error(transparent)]
16+
Gpio(#[from] GpioError),
17+
#[error(transparent)]
18+
Nix(#[from] NixError),
19+
#[error(transparent)]
20+
Io(#[from] IoError),
21+
#[error("{0}")]
22+
Msg(String),
23+
}
1824

19-
foreign_links {
20-
Gpio(GpioError);
21-
Nix(NixError);
22-
Io(IoError);
25+
impl From<String> for Error {
26+
fn from(msg: String) -> Error {
27+
Error::Msg(msg)
2328
}
2429
}
30+
31+
pub type Result<T> = std::result::Result<T, Error>;

0 commit comments

Comments
 (0)