diff options
-rw-r--r-- | CHANGELOG.md | 4 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/error.rs | 16 | ||||
-rw-r--r-- | src/util.rs | 2 |
4 files changed, 7 insertions, 17 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 736620d..121d0a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ Copyright (C) 2019-2020 Robin Krahl <robin.krahl@ireas.org> SPDX-License-Identifier: CC0-1.0 --> +# v0.7.1 (2020-08-30) +- Remove the custom `std::error::Error::source` implementation for + `error::Error` to avoid duplicate error messages. + # v0.7.0 (2020-07-14) - Refactor the `Error` enum so that it is `Send`, `Sync` and `'static`: - Remove the `sync::PoisonError` from the `PoisonError` variant. @@ -3,7 +3,7 @@ [package] name = "nitrokey" -version = "0.7.0" +version = "0.7.1" authors = ["Robin Krahl <robin.krahl@ireas.org>"] edition = "2018" homepage = "https://code.ireas.org/nitrokey-rs/" diff --git a/src/error.rs b/src/error.rs index 1aa1793..64a2ce0 100644 --- a/src/error.rs +++ b/src/error.rs @@ -91,21 +91,7 @@ impl<'a, T: device::Device<'a>> From<(T, Error)> for Error { } } -impl error::Error for Error { - fn source(&self) -> Option<&(dyn error::Error + 'static)> { - match *self { - Error::CommandError(ref err) => Some(err), - Error::CommunicationError(ref err) => Some(err), - Error::ConcurrentAccessError => None, - Error::LibraryError(ref err) => Some(err), - Error::PoisonError => None, - Error::UnexpectedError(_) => None, - Error::UnknownError(_) => None, - Error::UnsupportedModelError => None, - Error::Utf8Error(ref err) => Some(err), - } - } -} +impl error::Error for Error {} impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/src/util.rs b/src/util.rs index b17b071..26942cf 100644 --- a/src/util.rs +++ b/src/util.rs @@ -99,7 +99,7 @@ pub fn generate_password(length: usize) -> Result<CString, Error> { } pub fn get_cstring<T: Into<Vec<u8>>>(s: T) -> Result<CString, Error> { - CString::new(s).or_else(|_| Err(LibraryError::InvalidString.into())) + CString::new(s).map_err(|_| LibraryError::InvalidString.into()) } impl Into<i32> for LogLevel { |