keri_core/error/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
use said::version::error::Error as VersionError;
use serde::{Deserialize, Serialize};
use thiserror::Error;

use crate::{
    event::sections::key_config::SignatureError, event_message::cesr_adapter::ParseError,
    prefix::IdentifierPrefix, processor::validator::VerificationError,
};

pub mod serializer_error;

#[derive(Error, Debug, Serialize, Deserialize)]
pub enum Error {
    #[error("Error during Serialization: {0}")]
    SerializationError(String),

    #[error("Error while applying event: {0}")]
    SemanticError(String),

    #[error("Event signature verification faulty")]
    FaultySignatureVerification,

    #[error("Error while applying event: out of order event")]
    EventOutOfOrderError,

    #[error("Error while applying event: missing delegator source seal: {0}")]
    MissingDelegatorSealError(IdentifierPrefix),

    #[error("Error while applying event: missing delegating event")]
    MissingDelegatingEventError,

    #[error("Error while applying event: duplicate event")]
    EventDuplicateError,

    #[error("Not enough signatures while verifying")]
    NotEnoughSigsError,

    #[error("Not enough receipts")]
    NotEnoughReceiptsError,

    #[error("Event not yet in database")]
    MissingEvent,

    #[error("Event has no signatures")]
    MissingSignatures,

    #[error("No signer")]
    MissingSigner,

    #[error("No signer identifier in db {0}")]
    UnknownSigner(IdentifierPrefix),

    #[error("Signature verification failed")]
    SignatureVerificationError,

    #[error("Receipt signature verification failed")]
    ReceiptVerificationError,

    #[error("Deserialize error: {0}")]
    DeserializeError(#[from] ParseError),

    #[error("Identifier is not indexed into the DB")]
    NotIndexedError,

    #[error("Identifier ID is already present in the DB")]
    IdentifierPresentError,

    #[error("Failed to obtain mutable ref to Ark of KeyManager")]
    MutArcKeyVaultError,

    #[error("Sled error")]
    SledError,

    #[error("Keri serializer error: {0}")]
    SerdeSerError(#[from] serializer_error::Error),

    #[error("mutex is poisoned")]
    MutexPoisoned,

    #[error("Incorrect event digest")]
    IncorrectDigest,

    #[error("No digest of event set")]
    EventDigestError,

    #[cfg(feature = "query")]
    #[error(transparent)]
    QueryError(#[from] crate::query::QueryError),

    #[error(transparent)]
    DbError(#[from] crate::database::DbError),

    #[error("Event generation error: {0}")]
    EventGenerationError(String),

    #[error(transparent)]
    PrefixModuleError(#[from] crate::prefix::error::Error),

    #[error("CESR error")]
    CesrError,

    #[error("Version error")]
    VersionError,

    #[error("SAI error")]
    SAIError,

    #[error("Signing error")]
    SigningError,

    #[error(transparent)]
    KeyConfigError(SignatureError),

    #[error(transparent)]
    VerificationError(#[from] VerificationError),
}

impl From<VersionError> for Error {
    fn from(_: VersionError) -> Self {
        Error::VersionError
    }
}

impl From<said::error::Error> for Error {
    fn from(_: said::error::Error) -> Self {
        Error::SAIError
    }
}

impl From<sled::Error> for Error {
    fn from(_: sled::Error) -> Self {
        Error::SledError
    }
}

impl From<crate::keys::KeysError> for Error {
    fn from(_: crate::keys::KeysError) -> Self {
        Error::SigningError
    }
}

impl From<SignatureError> for Error {
    fn from(value: SignatureError) -> Self {
        match value {
            SignatureError::NotEnoughSigsError => Error::NotEnoughSigsError,
            e => Error::KeyConfigError(e),
        }
    }
}