Skip to content

Commit 3959b3c

Browse files
committed
Switch from failure to thiserror.
1 parent d16665b commit 3959b3c

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2018"
66

77
[dependencies]
88
bitflags = "1.0"
9-
failure = "0.1"
10-
libc = "=0.2.59"
9+
libc = "0.2.65"
1110
nix = "0.13"
11+
thiserror = "1.0.4"
1212
userfaultfd-sys = { path = "userfaultfd-sys" }

src/error.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::IoctlFlags;
2-
use failure::Fail;
2+
use thiserror::Error;
33
use nix::errno::Errno;
44

55
pub type Result<T> = std::result::Result<T, Error>;
@@ -10,38 +10,38 @@ pub type Result<T> = std::result::Result<T, Error>;
1010
/// [`userfaultfd(2)`](http://man7.org/linux/man-pages/man2/userfaultfd.2.html) and
1111
/// [`ioctl_userfaultfd(2)`](http://man7.org/linux/man-pages/man2/ioctl_userfaultfd.2.html) for more
1212
/// details on how to interpret these errors.
13-
#[derive(Debug, Fail)]
13+
#[derive(Debug, Error)]
1414
pub enum Error {
1515
/// Copy ioctl failure with `errno` value.
16-
#[fail(display = "copy failed: {}", 0)]
16+
#[error("Copy failed")]
1717
CopyFailed(Errno),
1818

1919
/// Failure to read a full `uffd_msg` struct from the underlying file descriptor.
20-
#[fail(display = "incomplete uffd_msg; read only {}/{} bytes", read, expected)]
20+
#[error("Incomplete uffd_msg; read only {read}/{expected} bytes")]
2121
IncompleteMsg { read: usize, expected: usize },
2222

2323
/// Generic system error.
24-
#[fail(display = "system error: {}", 0)]
25-
SystemError(nix::Error),
24+
#[error("System error")]
25+
SystemError(#[source] nix::Error),
2626

2727
/// End-of-file was read from the underlying file descriptor.
28-
#[fail(display = "EOF when reading file descriptor")]
28+
#[error("EOF when reading file descriptor")]
2929
ReadEof,
3030

3131
/// An unrecognized event code was found in a `uffd_msg` struct.
32-
#[fail(display = "unrecognized event in uffd_msg: {}", 0)]
32+
#[error("Unrecognized event in uffd_msg: {0}")]
3333
UnrecognizedEvent(u8),
3434

3535
/// An unrecognized ioctl bit was set in the result of API initialization or registration.
36-
#[fail(display = "unrecognized ioctl flags: {}", 0)]
36+
#[error("Unrecognized ioctl flags: {0}")]
3737
UnrecognizedIoctls(u64),
3838

3939
/// Requested ioctls were not available when initializing the API.
40-
#[fail(display = "requested ioctls unsupported; supported: {:?}", 0)]
40+
#[error("Requested ioctls unsupported; supported: {0:?}")]
4141
UnsupportedIoctls(IoctlFlags),
4242

4343
/// Zeropage ioctl failure with `errno` value.
44-
#[fail(display = "zeropage failed: {}", 0)]
44+
#[error("Zeropage failed: {0}")]
4545
ZeropageFailed(Errno),
4646
}
4747

0 commit comments

Comments
 (0)