voa_openpgp/
error.rs

1//! Error handling.
2
3use std::path::PathBuf;
4
5/// The error that can occur when using OpenPGP verifiers in VOA.
6#[derive(Debug, thiserror::Error)]
7pub enum Error {
8    /// An error occurred during import of an OpenPGP certificate.
9    #[error("Import error:\n{0}")]
10    Import(#[from] crate::import::error::Error),
11
12    /// An I/O error occurred at a path.
13    #[error("I/O error at path {path} while {context}:\n{source}")]
14    IoPath {
15        /// The path at which the error occurred.
16        path: PathBuf,
17
18        /// The context in which the error occurred.
19        ///
20        /// This is meant to complete the sentence "I/O error at path XXX while ...".
21        context: &'static str,
22
23        /// The source error.
24        source: std::io::Error,
25    },
26
27    /// An OpenPGP error occurred at a specific path.
28    #[error("OpenPGP error at path {path:?} while {context}:\n{source}")]
29    OpenPgpPath {
30        /// The path at which the error occurred.
31        path: PathBuf,
32
33        /// The context in which the error occurred.
34        ///
35        /// This is meant to complete the sentence "OpenPGP error at path {path} while ...".
36        context: &'static str,
37
38        /// The source error.
39        source: pgp::errors::Error,
40    },
41
42    /// An OpenPGP error occurred.
43    #[error("OpenPGP error while {context}:\n{source}")]
44    OpenPgp {
45        /// The context in which the error occurred.
46        ///
47        /// This is meant to complete the sentence "OpenPGP error while ...".
48        context: &'static str,
49
50        /// The source error.
51        source: pgp::errors::Error,
52    },
53
54    /// An VOA core error occurred.
55    #[error("VOA core error:\n{0}")]
56    VoaCore(#[from] voa_core::Error),
57
58    /// No applicable signature verification component key.
59    #[error("No applicable OpenPGP signature verification component key found in {fingerprint}")]
60    NoVerificationKey {
61        /// The fingerprint of the verifier in which the error occurred.
62        fingerprint: String,
63    },
64
65    /// The signature could not be verified with this certificate.
66    #[error("Signature verification failed with this verifier")]
67    SignatureNotValid,
68}