Skip to main content

anp_identity/
error.rs

1use thiserror::Error;
2
3pub type DidResult<T> = Result<T, DidError>;
4
5#[derive(Debug, Error, PartialEq, Eq)]
6pub enum DidError {
7    #[error("the DID domain is invalid")]
8    InvalidDomain,
9    #[error("at least one non-empty DID path segment is required")]
10    EmptyPath,
11    #[error("the DID path segment is invalid")]
12    InvalidPathSegment,
13    #[error("the KID fragment is invalid")]
14    InvalidKidFragment,
15    #[error("exactly one managed root-control key is required")]
16    InvalidManagedRootCount,
17    #[error("an external root-control key is forbidden")]
18    ExternalRootControl,
19    #[error("DID-WBA requires at least one managed request-signing key")]
20    MissingManagedRequestSigning,
21    #[error("a KID belongs to another DID")]
22    ForeignKid,
23    #[error("a canonical KID is duplicated")]
24    DuplicateKid,
25    #[error("the public key is invalid or incompatible with its role")]
26    InvalidPublicKey,
27    #[error("the service definition is invalid")]
28    InvalidService,
29    #[error("the extension definition is invalid")]
30    InvalidExtension,
31    #[error("the DID store is not initialized")]
32    StoreNotFound,
33    #[error("the root-key provider is unavailable")]
34    ProviderUnavailable,
35    #[error("the root key does not match this store")]
36    RootKeyMismatch,
37    #[error("the encrypted record is damaged")]
38    CorruptRecord,
39    #[error("the requested secret does not exist")]
40    SecretNotFound,
41    #[error("the requested identity does not exist")]
42    IdentityNotFound,
43    #[error("the DID identity already exists")]
44    DuplicateIdentity,
45    #[error("the requested KID does not exist")]
46    KeyNotFound,
47    #[error("the requested KID is external and has no managed private key")]
48    ExternalKeyOperation,
49    #[error("the key role does not authorize this operation")]
50    KeyRoleViolation,
51    #[error("the key state does not authorize this operation")]
52    KeyNotUsable,
53    #[error("the managed key material was already erased")]
54    KeyMaterialErased,
55    #[error("the root-transfer envelope or evidence is invalid")]
56    InvalidRootTransfer,
57    #[error("the root-transfer envelope is expired or outside the accepted time window")]
58    RootTransferExpired,
59    #[error("the root capability does not authorize this operation")]
60    RootCapabilityUnavailable,
61    #[error("another root transfer is already pending")]
62    PendingRootTransferExists,
63    #[error("the peer public key is invalid")]
64    InvalidPeerKey,
65    #[error("signature verification failed")]
66    VerificationFailed,
67    #[error("an identity already has a pending document revision")]
68    PendingRevisionExists,
69    #[error("the pending document revision does not exist")]
70    PendingRevisionNotFound,
71    #[error("the document revision is not in a valid publication state for this operation")]
72    InvalidPublicationState,
73    #[error("the identity document or local identity record is invalid")]
74    InvalidIdentity,
75    #[error("the store generation changed")]
76    Conflict,
77    #[error("filesystem operation failed: {0}")]
78    Io(String),
79    #[error("serialization failed: {0}")]
80    Serialization(String),
81    #[error("cryptographic operation failed")]
82    Crypto,
83    #[error("the requested operation is not supported in v1")]
84    UnsupportedOperation,
85}