diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-08-29 13:20:53 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-08-30 16:52:39 +0200 |
commit | 9fe16b02919a45f192372fc1250293f4ccfa040d (patch) | |
tree | 72cb23d978ad88eed4791ea4d65ee0900db58605 /openpgp | |
parent | 50d651a5f4045dccfcb2aec09bec44d5a92958f8 (diff) |
openpgp: Improve error handling.
Diffstat (limited to 'openpgp')
-rw-r--r-- | openpgp/src/serialize/partial_body.rs | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/openpgp/src/serialize/partial_body.rs b/openpgp/src/serialize/partial_body.rs index cdadea76..398a553b 100644 --- a/openpgp/src/serialize/partial_body.rs +++ b/openpgp/src/serialize/partial_body.rs @@ -100,22 +100,13 @@ impl<'a, C: 'a> PartialBodyFilter<'a, C> { unimplemented!(); } BodyLength::Full(l as u32).serialize(inner).map_err( - |e| { - match e.downcast::<io::Error>() { + |e| match e.downcast::<io::Error>() { + // An io::Error. Pass as-is. Ok(err) => err, - Err(e) => { - match e.downcast::<Error>() - .expect("Unexpected error encoding full length") - { - Error::InvalidArgument(s) => - panic!("Error encoding full length: {}", s), - _ => - panic!("Unexpected error encoding \ - full length"), - } - } - } - })?; + // A failure. Create a compat object and wrap it. + Err(e) => io::Error::new(io::ErrorKind::Other, + e.compat()), + })?; // Write the body. inner.write_all(&self.buffer[..])?; |