signstar_yubihsm2/
error.rs

1//! Error handling.
2
3/// The error that may occur when using a YubiHSM2 device.
4#[derive(Debug, thiserror::Error)]
5pub enum Error {
6    /// A client operation failed.
7    #[error("YubiHSM client operation failed while {context}:\n{source}")]
8    Client {
9        /// The context in which the error occurred.
10        ///
11        /// This is meant to complete the sentence "YubiHSM client operation failed while ".
12        context: &'static str,
13
14        /// The source error.
15        source: yubihsm::client::Error,
16    },
17
18    /// A device operation failed.
19    #[error("YubiHSM device operation failed while {context}:\n{source}")]
20    Device {
21        /// The context in which the error occurred.
22        ///
23        /// This is meant to complete the sentence "YubiHSM device operation failed while ".
24        context: &'static str,
25
26        /// The source error.
27        source: yubihsm::device::Error,
28    },
29
30    /// A device operation failed.
31    #[error("Certificate generation failed while {context}:\n{source}")]
32    CertificateGeneration {
33        /// The context in which the error occurred.
34        ///
35        /// This is meant to complete the sentence "Certificate generation failed while ".
36        context: &'static str,
37
38        /// The source error.
39        source: signstar_crypto::signer::error::Error,
40    },
41}