use proper Result instead of Option for encryption and decryption

This commit is contained in:
dignifiedquire
2019-09-18 17:07:28 +02:00
committed by holger krekel
parent cee0e22ce7
commit 8667de994e
4 changed files with 82 additions and 70 deletions

View File

@@ -24,6 +24,8 @@ pub enum Error {
Utf8(std::str::Utf8Error),
#[fail(display = "{:?}", _0)]
CStringError(crate::dc_tools::CStringError),
#[fail(display = "PGP: {:?}", _0)]
Pgp(pgp::errors::Error),
}
pub type Result<T> = std::result::Result<T, Error>;
@@ -70,6 +72,12 @@ impl From<crate::dc_tools::CStringError> for Error {
}
}
impl From<pgp::errors::Error> for Error {
fn from(err: pgp::errors::Error) -> Error {
Error::Pgp(err)
}
}
#[macro_export]
macro_rules! bail {
($e:expr) => {