summaryrefslogtreecommitdiffstats
path: root/guide
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2020-03-09 11:42:45 +0100
committerJustus Winter <justus@sequoia-pgp.org>2020-03-09 18:09:50 +0100
commit391a4b92c977cd64dfd131f3e29b0bc8d756d064 (patch)
treeb5b96ff935853cef9ee22e01890c248a791e724e /guide
parent58d662c6d37dd1b0dccd4d0ce30290b8ede408e9 (diff)
Switch from failure to anyhow.
- Use the anyhow crate instead of failure to implement the dynamic side of our error handling. anyhow::Error derefs to dyn std::error::Error, allowing better interoperability with other stdlib-based error handling libraries. - Fixes #444.
Diffstat (limited to 'guide')
-rw-r--r--guide/Cargo.toml2
-rw-r--r--guide/src/chapter_01.md28
2 files changed, 13 insertions, 17 deletions
diff --git a/guide/Cargo.toml b/guide/Cargo.toml
index 5f53762b..28e91690 100644
--- a/guide/Cargo.toml
+++ b/guide/Cargo.toml
@@ -13,4 +13,4 @@ build = "build.rs"
[dependencies]
sequoia-openpgp = { path = "../openpgp", version = "0.15" }
-failure = "0.1.2"
+anyhow = "1"
diff --git a/guide/src/chapter_01.md b/guide/src/chapter_01.md
index b6c05d21..e2c2a88f 100644
--- a/guide/src/chapter_01.md
+++ b/guide/src/chapter_01.md
@@ -12,7 +12,6 @@ fragments yields the [`openpgp/examples/generate-sign-verify.rs`].
use std::io::{self, Write};
use std::convert::TryInto;
-extern crate failure;
extern crate sequoia_openpgp as openpgp;
use openpgp::cert::prelude::*;
use openpgp::serialize::stream::*;
@@ -132,10 +131,10 @@ fn main() {
# Some(Err(e)) =>
# return Err(openpgp::Error::from(e).into()),
# None =>
-# return Err(failure::err_msg("No signature")),
+# return Err(anyhow::anyhow!("No signature")),
# }
# },
-# _ => return Err(failure::err_msg(
+# _ => return Err(anyhow::anyhow!(
# "Unexpected message structure")),
# }
# }
@@ -143,7 +142,7 @@ fn main() {
# if good {
# Ok(()) // Good signature.
# } else {
-# Err(failure::err_msg("Signature verification failed"))
+# Err(anyhow::anyhow!("Signature verification failed"))
# }
# }
# }
@@ -161,7 +160,6 @@ create it:
# use std::io::{self, Write};
# use std::convert::TryInto;
#
-# extern crate failure;
# extern crate sequoia_openpgp as openpgp;
# use openpgp::cert::prelude::*;
# use openpgp::serialize::stream::*;
@@ -281,10 +279,10 @@ fn generate() -> openpgp::Result<openpgp::Cert> {
# Some(Err(e)) =>
# return Err(openpgp::Error::from(e).into()),
# None =>
-# return Err(failure::err_msg("No signature")),
+# return Err(anyhow::anyhow!("No signature")),
# }
# },
-# _ => return Err(failure::err_msg(
+# _ => return Err(anyhow::anyhow!(
# "Unexpected message structure")),
# }
# }
@@ -292,7 +290,7 @@ fn generate() -> openpgp::Result<openpgp::Cert> {
# if good {
# Ok(()) // Good signature.
# } else {
-# Err(failure::err_msg("Signature verification failed"))
+# Err(anyhow::anyhow!("Signature verification failed"))
# }
# }
# }
@@ -310,7 +308,6 @@ implements [`io::Write`], and we simply write the plaintext to it.
# use std::io::{self, Write};
# use std::convert::TryInto;
#
-# extern crate failure;
# extern crate sequoia_openpgp as openpgp;
# use openpgp::cert::prelude::*;
# use openpgp::serialize::stream::*;
@@ -430,10 +427,10 @@ fn sign(policy: &dyn Policy,
# Some(Err(e)) =>
# return Err(openpgp::Error::from(e).into()),
# None =>
-# return Err(failure::err_msg("No signature")),
+# return Err(anyhow::anyhow!("No signature")),
# }
# },
-# _ => return Err(failure::err_msg(
+# _ => return Err(anyhow::anyhow!(
# "Unexpected message structure")),
# }
# }
@@ -441,7 +438,7 @@ fn sign(policy: &dyn Policy,
# if good {
# Ok(()) // Good signature.
# } else {
-# Err(failure::err_msg("Signature verification failed"))
+# Err(anyhow::anyhow!("Signature verification failed"))
# }
# }
# }
@@ -470,7 +467,6 @@ Verified data can be read from this using [`io::Read`].
# use std::io::{self, Write};
# use std::convert::TryInto;
#
-# extern crate failure;
# extern crate sequoia_openpgp as openpgp;
# use openpgp::cert::prelude::*;
# use openpgp::serialize::stream::*;
@@ -590,10 +586,10 @@ impl<'a> VerificationHelper for Helper<'a> {
Some(Err(e)) =>
return Err(openpgp::Error::from(e).into()),
None =>
- return Err(failure::err_msg("No signature")),
+ return Err(anyhow::anyhow!("No signature")),
}
},
- _ => return Err(failure::err_msg(
+ _ => return Err(anyhow::anyhow!(
"Unexpected message structure")),
}
}
@@ -601,7 +597,7 @@ impl<'a> VerificationHelper for Helper<'a> {
if good {
Ok(()) // Good signature.
} else {
- Err(failure::err_msg("Signature verification failed"))
+ Err(anyhow::anyhow!("Signature verification failed"))
}
}
}