summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-08-29 13:20:53 +0200
committerJustus Winter <justus@sequoia-pgp.org>2019-08-30 16:52:39 +0200
commit9fe16b02919a45f192372fc1250293f4ccfa040d (patch)
tree72cb23d978ad88eed4791ea4d65ee0900db58605
parent50d651a5f4045dccfcb2aec09bec44d5a92958f8 (diff)
openpgp: Improve error handling.
-rw-r--r--openpgp/src/serialize/partial_body.rs21
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[..])?;