summaryrefslogtreecommitdiffstats
path: root/sqv
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2020-03-27 17:16:15 +0100
committerJustus Winter <justus@sequoia-pgp.org>2020-03-27 17:58:29 +0100
commit49c76d957f1e03165124fe0ffc6a7da4cae062e6 (patch)
treec2864e970ef4cfa210e792fd72b5722436fce9af /sqv
parent277dc695e015e4997b982939967578a0138a4f88 (diff)
sqv: Improve error reporting.
Diffstat (limited to 'sqv')
-rw-r--r--sqv/src/sqv.rs30
1 files changed, 20 insertions, 10 deletions
diff --git a/sqv/src/sqv.rs b/sqv/src/sqv.rs
index 74e2d078..886bcd43 100644
--- a/sqv/src/sqv.rs
+++ b/sqv/src/sqv.rs
@@ -145,9 +145,11 @@ impl<'a> VerificationHelper for VHelper<'a> {
self.not_before,
self.not_after)
{
- (None, _, _) =>
- eprintln!("Malformed signature: \
- no signature creation time"),
+ (None, _, _) => {
+ eprintln!("Malformed signature:");
+ print_error_chain(&anyhow::anyhow!(
+ "no signature creation time"));
+ },
(Some(t), Some(not_before), not_after) => {
if t < not_before {
eprintln!(
@@ -176,7 +178,8 @@ impl<'a> VerificationHelper for VHelper<'a> {
};
}
Err(MalformedSignature { error, .. }) => {
- eprintln!("Signature is malformed: {}", error);
+ eprintln!("Signature is malformed:");
+ print_error_chain(&error);
}
Err(MissingKey { sig, .. }) => {
let issuers = sig.get_issuers();
@@ -185,16 +188,18 @@ impl<'a> VerificationHelper for VHelper<'a> {
issuers.first().unwrap());
}
Err(UnboundKey { cert, error, .. }) => {
- eprintln!("Signing key on {:X} is not bound: {}",
- cert.fingerprint(), error);
+ eprintln!("Signing key on {:X} is not bound:",
+ cert.fingerprint());
+ print_error_chain(&error);
}
Err(BadKey { ka, error, .. }) => {
- eprintln!("Signing key on {:X} is bad: {}",
- ka.cert().fingerprint(),
- error);
+ eprintln!("Signing key on {:X} is bad:",
+ ka.cert().fingerprint());
+ print_error_chain(&error);
}
Err(BadSignature { error, .. }) => {
- eprintln!("Verifying signature: {}.", error);
+ eprintln!("Verifying signature:");
+ print_error_chain(&error);
if verification_err.is_none() {
verification_err = Some(error)
}
@@ -221,6 +226,11 @@ impl<'a> VerificationHelper for VHelper<'a> {
}
}
+fn print_error_chain(err: &anyhow::Error) {
+ eprintln!(" {}", err);
+ err.chain().skip(1).for_each(|cause| eprintln!(" because: {}", cause));
+}
+
fn main() -> Result<()> {
let p = &P::new();