diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-01-16 17:02:11 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-01-16 17:02:11 +0100 |
commit | 4477f74b07070bdd95a228cd4b97dd5f9fb70aaf (patch) | |
tree | 5c66d334e6aea11e0a092a3c552da9376cb0fcda /ffi/src | |
parent | 99ad668da45db0d74b74d1e4888f1c286130c6a4 (diff) |
ffi: Introduce setter for the error in the Context.
Diffstat (limited to 'ffi/src')
-rw-r--r-- | ffi/src/core.rs | 6 | ||||
-rw-r--r-- | ffi/src/lib.rs | 4 | ||||
-rw-r--r-- | ffi/src/openpgp/armor.rs | 2 | ||||
-rw-r--r-- | ffi/src/openpgp/mod.rs | 2 |
4 files changed, 9 insertions, 5 deletions
diff --git a/ffi/src/core.rs b/ffi/src/core.rs index de44a8bd..05cd1279 100644 --- a/ffi/src/core.rs +++ b/ffi/src/core.rs @@ -56,13 +56,17 @@ use sequoia_core::Config; #[doc(hidden)] pub struct Context { pub(crate) c: core::Context, - pub(crate) e: Option<failure::Error>, + e: Option<failure::Error>, } impl Context { fn new(c: core::Context) -> Self { Context{c: c, e: None} } + + pub(crate) fn set_error(&mut self, e: failure::Error) { + self.e = Some(e); + } } /// Returns the last error. diff --git a/ffi/src/lib.rs b/ffi/src/lib.rs index f50c5d36..2085521c 100644 --- a/ffi/src/lib.rs +++ b/ffi/src/lib.rs @@ -277,7 +277,7 @@ macro_rules! ffi_make_fry_from_ctx { Ok(_) => Status::Success, Err(e) => { let status = Status::from(&e); - $ctx.e = Some(e); + $ctx.set_error(e); status }, } @@ -294,7 +294,7 @@ macro_rules! ffi_make_fry_from_ctx { match $expr { Ok(v) => v, Err(e) => { - $ctx.e = Some(e); + $ctx.set_error(e); return $or; }, } diff --git a/ffi/src/openpgp/armor.rs b/ffi/src/openpgp/armor.rs index 7616a03d..db6672d6 100644 --- a/ffi/src/openpgp/armor.rs +++ b/ffi/src/openpgp/armor.rs @@ -245,7 +245,7 @@ pub extern "system" fn sq_armor_reader_headers(ctx: *mut Context, buf }, Err(e) => { - ctx.e = Some(e); + ctx.set_error(e); ptr::null_mut() }, }; diff --git a/ffi/src/openpgp/mod.rs b/ffi/src/openpgp/mod.rs index 8dba85a1..c679b1d4 100644 --- a/ffi/src/openpgp/mod.rs +++ b/ffi/src/openpgp/mod.rs @@ -884,7 +884,7 @@ pub extern "system" fn sq_packet_parser_finish<'a> }, Err(e) => { let status = Status::from(&e); - ctx.e = Some(e); + ctx.set_error(e); status }, } |