Skip to content

Commit

Permalink
Merge pull request #8 from dbrgn/unwrap
Browse files Browse the repository at this point in the history
Get rid of .unwrap() in Error::fmt
  • Loading branch information
badboy authored Jun 25, 2016
2 parents a607296 + 1ae662f commit 45f4505
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ pub enum Error {

impl fmt::Display for Error {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!(fmt, "{}: {}", self.description(), self.cause().unwrap())
match self.cause() {
Some(cause) => write!(fmt, "{}: {}", self.description(), cause),
None => write!(fmt, "{}", self.description()),
}
}
}

Expand Down

0 comments on commit 45f4505

Please sign in to comment.