identity_storage/storage/
error.rs1use crate::key_id_storage::KeyIdStorageError;
5use crate::key_id_storage::MethodDigestConstructionError;
6use crate::key_storage::KeyStorageError;
7
8#[derive(Debug, thiserror::Error)]
10#[non_exhaustive]
11pub enum JwkStorageDocumentError {
12 #[error("storage operation failed: key storage error")]
14 KeyStorageError(KeyStorageError),
15 #[error("storage operation failed: key id storage error: {0}")]
17 KeyIdStorageError(KeyIdStorageError),
18 #[error("could not add method: the fragment already exists")]
20 FragmentAlreadyExists,
21 #[error("method not found")]
23 MethodNotFound,
24 #[error("invalid method data format: expected publicKeyJwk")]
26 NotPublicKeyJwk,
27 #[error("invalid method data format: expected compositePublicKey")]
29 NotCompositePublicKey,
30 #[error("invalid JWS algorithm")]
32 InvalidJwsAlgorithm,
33 #[error("invalid JWP algorithm")]
35 InvalidJwpAlgorithm,
36 #[error("Not able to construct a valid Jwp")]
38 JwpBuildingError,
39 #[error("Credential's proof internal error")]
41 ProofUpdateError(String),
42 #[error("method generation failed: unable to create a valid verification method")]
44 VerificationMethodConstructionError(#[source] identity_verification::Error),
45 #[error("could not produce jwt: encoding error")]
47 EncodingError(#[source] Box<dyn std::error::Error + Send + Sync + 'static>),
48 #[error("unable to produce method digest")]
50 MethodDigestConstructionError(#[source] MethodDigestConstructionError),
51 #[error("could not produce JWS payload from the given claims: serialization failed")]
53 ClaimsSerializationError(#[source] identity_credential::Error),
54 #[error("storage operation failed after altering state. Unable to undo operation(s): {message}")]
56 UndoOperationFailed {
57 message: String,
59 source: Box<Self>,
61 undo_error: Option<Box<Self>>,
63 },
64}
65
66#[cfg(test)]
67mod tests {
68 use super::JwkStorageDocumentError;
69 fn is_send_sync<T: Send + Sync + 'static>(_input: T) {}
70
71 #[test]
72 fn error_is_send_sync() {
73 is_send_sync(JwkStorageDocumentError::FragmentAlreadyExists);
74 }
75}