Skip to main content

affinidi_did_key/
errors.rs

1use affinidi_secrets_resolver::errors::SecretsResolverError;
2use thiserror::Error;
3
4/// Error states for did:key method
5#[derive(Error, Debug)]
6pub enum Error<'a> {
7    /// Wrong DID method or structure
8    #[error("Invalid DID ({0}) Error: {1}")]
9    InvalidDid(&'a str, String),
10
11    /// DID URL isn't valid
12    #[error("Invalid DID URL ({0}) Error: {1}")]
13    InvalidDidUrl(&'a str, String),
14
15    /// Public key string length doesn't match what is expected
16    #[error("Invalid public key length ({0})")]
17    InvalidPublicKeyLength(usize),
18
19    /// Public key value isn't valid for the crypto algorithm
20    #[error("Invalid public key error: {0}")]
21    InvalidPublicKey(String),
22
23    /// Unsupported Public Key type specified in the method
24    #[error("Unsupported public key type: {0}")]
25    UnsupportedPublicKeyType(String),
26
27    /// Invalid Public Key type specified
28    #[error("Invalid public key type: {0}")]
29    InvalidPublicKeyType(&'a str),
30
31    /// Couldn't generate did:key
32    #[error("Failed to generate did:key: {0}")]
33    GenerateError(#[from] SecretsResolverError),
34}