Skip to main content

affinidi_crypto/
error.rs

1//! Error types for cryptographic operations
2
3use thiserror::Error;
4
5/// This type is `#[non_exhaustive]`: callers must include a wildcard arm when
6/// matching, so future additions do not constitute breaking changes.
7#[derive(Error, Debug)]
8#[non_exhaustive]
9pub enum CryptoError {
10    #[error("Key error: {0}")]
11    KeyError(String),
12
13    #[error("Decoding error: {0}")]
14    Decoding(String),
15
16    #[error("Unsupported key type: {0}")]
17    UnsupportedKeyType(String),
18
19    #[error("Encoding error: {0}")]
20    Encoding(#[from] affinidi_encoding::EncodingError),
21
22    // ─── JOSE primitives (`jose` feature) ───────────────────────────────────
23    #[error("Key agreement error: {0}")]
24    KeyAgreement(String),
25
26    #[error("Key derivation error: {0}")]
27    KeyDerivation(String),
28
29    #[error("Key wrap error: {0}")]
30    KeyWrap(String),
31
32    #[error("Content encryption error: {0}")]
33    ContentEncryption(String),
34
35    #[error("Signing error: {0}")]
36    Signing(String),
37
38    #[error("Verification error: {0}")]
39    Verification(String),
40}
41
42pub type Result<T> = std::result::Result<T, CryptoError>;