diff options
-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 }, } |