Skip to main content

signstar_download_key_certificates/
error.rs

1//! Error handling.
2
3/// An error that may occur when downloading the certificates of signing keys.
4#[derive(Debug, thiserror::Error)]
5pub enum Error {
6    #[cfg(not(any(feature = "nethsm", feature = "yubihsm2")))]
7    /// No HSM backend support is compiled in.
8    #[error("No HSM backend support compiled in")]
9    NoBackend,
10
11    /// The configuration offers no connection for a backend.
12    #[cfg(any(feature = "nethsm", feature = "yubihsm2"))]
13    #[error("No connection set for the backend")]
14    NoConnection,
15
16    /// No credentials found for current system user.
17    #[cfg(any(feature = "nethsm", feature = "yubihsm2"))]
18    #[error("No credentials for the system user {user}")]
19    NoCredentials {
20        /// The username that does not have credentials associated.
21        user: String,
22    },
23
24    /// Configuration error.
25    #[error("Signstar config error: {0}")]
26    Config(#[from] signstar_config::Error),
27
28    /// Username cannot be converted to backend-specific format.
29    #[error("No credentials for the system user {user}")]
30    InvalidUser {
31        /// The username for which the conversion fails.
32        user: String,
33    },
34
35    /// NetHSM error.
36    #[cfg(feature = "nethsm")]
37    #[error("NetHSM error: {0}")]
38    NetHsm(#[from] nethsm::Error),
39
40    /// JSON serialization error.
41    #[error("JSON serialization error: {0}")]
42    Serialization(#[from] serde_json::Error),
43    /// A signstar-common error.
44
45    #[error(transparent)]
46    SignstarCommon(#[from] signstar_common::Error),
47
48    /// A signstar-crypto error.
49    #[error(transparent)]
50    SignstarCrypto(#[from] signstar_crypto::Error),
51
52    /// Signing key is using a key context that is unsupported.
53    #[error("Unsupported key context for signing key: {signing_key_id}")]
54    UnsupportedKeyContext {
55        /// The identifier of the signing key.
56        signing_key_id: String,
57    },
58
59    /// YubiHSM error.
60    #[cfg(feature = "yubihsm2")]
61    #[error(transparent)]
62    YubiHsm(#[from] signstar_yubihsm2::Error),
63}