keri_core/error/
mod.rs

1use said::version::error::Error as VersionError;
2use serde::{Deserialize, Serialize};
3use thiserror::Error;
4
5use crate::{
6    database::redb::RedbError, event::sections::key_config::SignatureError,
7    event_message::cesr_adapter::ParseError, prefix::IdentifierPrefix,
8    processor::validator::VerificationError,
9};
10
11pub mod serializer_error;
12
13#[derive(Error, Debug, Serialize, Deserialize)]
14pub enum Error {
15    #[error("Error during Serialization: {0}")]
16    SerializationError(String),
17
18    #[error("Error while applying event: {0}")]
19    SemanticError(String),
20
21    #[error("Event signature verification faulty")]
22    FaultySignatureVerification,
23
24    #[error("Error while applying event: out of order event")]
25    EventOutOfOrderError,
26
27    #[error("Error while applying event: missing delegator source seal: {0}")]
28    MissingDelegatorSealError(IdentifierPrefix),
29
30    #[error("Error while applying event: missing delegating event")]
31    MissingDelegatingEventError,
32
33    #[error("Error while applying event: duplicate event")]
34    EventDuplicateError,
35
36    #[error("Not enough signatures while verifying")]
37    NotEnoughSigsError,
38
39    #[error("Not enough receipts")]
40    NotEnoughReceiptsError,
41
42    #[error("Event not yet in database")]
43    MissingEvent,
44
45    #[error("Event has no signatures")]
46    MissingSignatures,
47
48    #[error("No signer")]
49    MissingSigner,
50
51    #[error("No signer identifier in db {0}")]
52    UnknownSigner(IdentifierPrefix),
53
54    #[error("Signature verification failed")]
55    SignatureVerificationError,
56
57    #[error("Receipt signature verification failed")]
58    ReceiptVerificationError,
59
60    #[error("Deserialize error: {0}")]
61    DeserializeError(#[from] ParseError),
62
63    #[error("Identifier is not indexed into the DB")]
64    NotIndexedError,
65
66    #[error("Identifier ID is already present in the DB")]
67    IdentifierPresentError,
68
69    #[error("Failed to obtain mutable ref to Ark of KeyManager")]
70    MutArcKeyVaultError,
71
72    #[error("Sled error")]
73    SledError,
74
75    #[error("Keri serializer error: {0}")]
76    SerdeSerError(#[from] serializer_error::Error),
77
78    #[error("mutex is poisoned")]
79    MutexPoisoned,
80
81    #[error("Incorrect event digest")]
82    IncorrectDigest,
83
84    #[error("No digest of event set")]
85    EventDigestError,
86
87    #[cfg(feature = "query")]
88    #[error(transparent)]
89    QueryError(#[from] crate::query::QueryError),
90
91    #[error("Database err")]
92    DbError,
93
94    #[error("Event generation error: {0}")]
95    EventGenerationError(String),
96
97    #[error(transparent)]
98    PrefixModuleError(#[from] crate::prefix::error::Error),
99
100    #[error("CESR error")]
101    CesrError,
102
103    #[error("Version error")]
104    VersionError,
105
106    #[error("SAI error")]
107    SAIError,
108
109    #[error("Signing error")]
110    SigningError,
111
112    #[error(transparent)]
113    KeyConfigError(SignatureError),
114
115    #[error(transparent)]
116    VerificationError(#[from] VerificationError),
117}
118
119impl From<VersionError> for Error {
120    fn from(_: VersionError) -> Self {
121        Error::VersionError
122    }
123}
124
125impl From<said::error::Error> for Error {
126    fn from(_: said::error::Error) -> Self {
127        Error::SAIError
128    }
129}
130
131impl From<RedbError> for Error {
132    fn from(_: RedbError) -> Self {
133        Error::DbError
134    }
135}
136
137impl From<crate::keys::KeysError> for Error {
138    fn from(_: crate::keys::KeysError) -> Self {
139        Error::SigningError
140    }
141}
142
143impl From<SignatureError> for Error {
144    fn from(value: SignatureError) -> Self {
145        match value {
146            SignatureError::NotEnoughSigsError => Error::NotEnoughSigsError,
147            e => Error::KeyConfigError(e),
148        }
149    }
150}