Skip to content

Commit 15f797b

Browse files
committed
Update errors to current best practices
1 parent a724bdd commit 15f797b

File tree

2 files changed

+1
-15
lines changed

2 files changed

+1
-15
lines changed

examples/nunchuck.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,12 @@ mod nunchuck {
4040
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
4141
match *self {
4242
NunchuckError::Error(ref e) => fmt::Display::fmt(e, f),
43-
NunchuckError::ParseError => fmt::Display::fmt(self.description(), f),
43+
NunchuckError::ParseError => write!(f, "Could not parse data"),
4444
}
4545
}
4646
}
4747

4848
impl<E: Error> Error for NunchuckError<E> {
49-
fn description(&self) -> &str {
50-
match *self {
51-
NunchuckError::Error(ref e) => e.description(),
52-
NunchuckError::ParseError => "Unable to Parse Data",
53-
}
54-
}
55-
5649
fn cause(&self) -> Option<&dyn Error> {
5750
match *self {
5851
NunchuckError::Error(ref e) => Some(e),

src/linux.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,6 @@ impl fmt::Display for LinuxI2CError {
7272
}
7373

7474
impl Error for LinuxI2CError {
75-
fn description(&self) -> &str {
76-
match *self {
77-
LinuxI2CError::Io(ref e) => e.description(),
78-
LinuxI2CError::Nix(ref e) => e.description(),
79-
}
80-
}
81-
8275
fn cause(&self) -> Option<&dyn Error> {
8376
match *self {
8477
LinuxI2CError::Io(ref e) => Some(e),

0 commit comments

Comments
 (0)