Skip to main content

co_didcomm/
error.rs

1use std::str::Utf8Error;
2
3/// `Error` type used througout crate
4#[derive(Debug, thiserror::Error)]
5pub enum Error {
6    #[error("plugged cryptography failure")]
7    PlugCryptoFailure,
8    #[error("not a rotation message")]
9    NoRotationData,
10    #[error("malformed DID string")]
11    BadDid,
12    #[error("no recipient set for jwe")]
13    NoJweRecipient,
14    #[error("not a JWS compact representation")]
15    JwsParseError,
16    #[error("failed to parse as JWE")]
17    JweParseError,
18    #[error("JWM header parsing failed - malformed alg")]
19    JwmHeaderParseError,
20    #[error("cannot resolve did document from JWE header from field")]
21    DidResolveFailed,
22    #[error("invalid key size {0}")]
23    InvalidKeySize(String),
24    #[error("{0} is not set")]
25    PropertyIsNotSet(&'static str),
26    #[error("{0}")]
27    Generic(String),
28    #[error(transparent)]
29    SerdeError(#[from] serde_json::Error),
30    #[error(transparent)]
31    RegexError(#[from] regex::Error),
32    #[cfg(feature = "jose-biscuit")]
33    #[error(transparent)]
34    BisquitError(#[from] biscuit::errors::Error),
35    #[error(transparent)]
36    TryFromError(#[from] core::convert::Infallible),
37    #[error(transparent)]
38    Utf8ParseError(#[from] Utf8Error),
39    #[cfg(feature = "raw-crypto")]
40    #[error(transparent)]
41    EdDsaError(#[from] ed25519_dalek::SignatureError),
42    #[error(transparent)]
43    StringConversionError(#[from] std::string::FromUtf8Error),
44    #[error(transparent)]
45    SystemTimeError(#[from] std::time::SystemTimeError),
46    #[error(transparent)]
47    Base64DecodeError(#[from] base64_url::base64::DecodeError),
48    #[error("invalid attachment{0}")]
49    AttachmentError(String),
50    #[error(transparent)]
51    Other(Box<dyn std::error::Error + Send + Sync>),
52}