Skip to content

Commit abfcf7b

Browse files
committed
refactor: use thiserror to replace failure
1 parent 19b207b commit abfcf7b

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,4 @@ edition = "2018"
1818
travis-ci = { repository = "aesedepece/limits-rs" }
1919

2020
[dependencies]
21-
failure = "0.1.6"
22-
failure_derive = "0.1.6"
21+
thiserror = "1.0"

src/lib.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
//!
88
//! Support for other operating systems and platforms may be added on demand.
99
10-
#[macro_use]
11-
extern crate failure_derive;
10+
use thiserror::Error;
1211

1312
// Support for GNU/Linux
1413
#[cfg(target_os = "linux")]
@@ -24,12 +23,12 @@ pub use crate::default::*;
2423

2524
/// All methods that can fail in this crate should return `Result<_, Error>`. That is, one of the
2625
/// variants herein.
27-
#[derive(Debug, Fail)]
26+
#[derive(Debug, Error)]
2827
pub enum Error {
29-
#[fail(display = "Unsupported OS. Could not get process limits.")]
28+
#[error("Unsupported OS. Could not get process limits.")]
3029
UnsupportedOS,
31-
#[fail(display = "Proc file not found at `{}`: {}", _0, _1)]
32-
ProcFileNotFound(String, #[cause] std::io::Error),
30+
#[error("Proc file not found at `{}`: {}", .0, .1)]
31+
ProcFileNotFound(String, #[source] std::io::Error),
3332
}
3433

3534
/// Get the limits for the process in which we are running (our own process id).

0 commit comments

Comments
 (0)