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(transparent)]
92 SledDbError(#[from] crate::database::sled::DbError),
93
94 #[error("Database err")]
95 DbError,
96
97 #[error("Event generation error: {0}")]
98 EventGenerationError(String),
99
100 #[error(transparent)]
101 PrefixModuleError(#[from] crate::prefix::error::Error),
102
103 #[error("CESR error")]
104 CesrError,
105
106 #[error("Version error")]
107 VersionError,
108
109 #[error("SAI error")]
110 SAIError,
111
112 #[error("Signing error")]
113 SigningError,
114
115 #[error(transparent)]
116 KeyConfigError(SignatureError),
117
118 #[error(transparent)]
119 VerificationError(#[from] VerificationError),
120}
121
122impl From<VersionError> for Error {
123 fn from(_: VersionError) -> Self {
124 Error::VersionError
125 }
126}
127
128impl From<said::error::Error> for Error {
129 fn from(_: said::error::Error) -> Self {
130 Error::SAIError
131 }
132}
133
134impl From<sled::Error> for Error {
135 fn from(_: sled::Error) -> Self {
136 Error::SledError
137 }
138}
139
140impl From<RedbError> for Error {
141 fn from(_: RedbError) -> Self {
142 Error::DbError
143 }
144}
145
146impl From<crate::keys::KeysError> for Error {
147 fn from(_: crate::keys::KeysError) -> Self {
148 Error::SigningError
149 }
150}
151
152impl From<SignatureError> for Error {
153 fn from(value: SignatureError) -> Self {
154 match value {
155 SignatureError::NotEnoughSigsError => Error::NotEnoughSigsError,
156 e => Error::KeyConfigError(e),
157 }
158 }
159}