Skip to main content

nethsm/
error.rs

1//! Error handling for [`NetHsm`].
2
3#[cfg(doc)]
4use crate::{NetHsm, connection};
5
6/// An error that may occur when using a NetHSM.
7#[derive(Debug, thiserror::Error)]
8pub enum Error {
9    /// A Base64 encoded string can not be decode
10    #[error("Decoding Base64 string failed: {0}")]
11    Base64Decode(#[from] base64ct::Error),
12
13    /// A generic error with a custom message
14    #[error("NetHSM error: {0}")]
15    Default(String),
16
17    /// A call to the NetHSM API failed
18    #[error("NetHSM API error: {0}")]
19    Api(String),
20
21    /// An error occurred in the [`connection`] module.
22    #[error("NetHSM connection error:\n{0}")]
23    Connection(#[from] crate::connection::Error),
24
25    /// An error with a key occurred
26    #[error("Key error: {0}")]
27    Key(#[from] crate::key::Error),
28
29    /// User data error
30    #[error("User data error: {0}")]
31    User(#[from] crate::user::Error),
32
33    /// A [`signstar_crypto::Error`] occurred.
34    #[error(transparent)]
35    SignstarCrypto(#[from] signstar_crypto::Error),
36
37    /// An compatibility issue occurred in the NetHSM SDK translation interface.
38    #[error("Compatibility issue with nethsm-sdk-rs: {0}")]
39    NetHsmSdkRsCompatibility(#[from] crate::nethsm_sdk::Error),
40}