ave_core/request/
error.rs1use ave_actors::ActorError;
2use ave_common::identity::DigestIdentifier;
3use thiserror::Error;
4
5use crate::{
6 governance::error::GovernanceError,
7 model::error::{LedgerError, ProtocolsError},
8};
9
10#[derive(Debug, Error, Clone)]
11pub enum RequestHandlerError {
12 #[error("helpers are not initialized")]
14 HelpersNotInitialized,
15
16 #[error("the payload cannot be deserialized as a governance event")]
17 GovFactInvalidEvent,
18
19 #[error("governance fact events cannot define viewpoints")]
20 GovFactViewpointsNotAllowed,
21
22 #[error("invalid tracker fact viewpoints: {0}")]
23 InvalidTrackerFactViewpoints(String),
24
25 #[error(
26 "tracker subject '{0}' cannot emit events because the local ledger is not full"
27 )]
28 TrackerLedgerNotFull(String),
29
30 #[error("a user cannot mark a request approval as obsolete")]
32 ObsoleteApproval,
33
34 #[error(
36 "no approval found for subject '{0}', node likely no longer has approver role"
37 )]
38 ApprovalNotFound(String),
39
40 #[error("failed to change approval state")]
42 ApprovalChangeFailed,
43
44 #[error("failed to get approval state")]
46 ApprovalGetFailed,
47
48 #[error("not the owner of subject '{0}'")]
50 NotOwner(String),
51
52 #[error("subject '{0}' has a pending new owner")]
54 PendingNewOwner(String),
55
56 #[error("signer is the owner of subject '{0}', cannot confirm/reject")]
58 IsOwner(String),
59
60 #[error("signer is not the new owner of subject '{0}'")]
62 NotNewOwner(String),
63
64 #[error("no new owner pending for subject '{0}'")]
66 NoNewOwnerPending(String),
67
68 #[error("subject name must be between 1 and 100 characters")]
70 InvalidName,
71
72 #[error("subject description must be between 1 and 200 characters")]
74 InvalidDescription,
75
76 #[error("invalid schema_id in request")]
78 InvalidSchemaId,
79
80 #[error("governance creation must have empty governance_id")]
82 GovernanceIdMustBeEmpty,
83
84 #[error("governance creation must have empty namespace")]
86 NamespaceMustBeEmpty,
87
88 #[error("non-governance creation must have a governance_id")]
90 GovernanceIdRequired,
91
92 #[error("transfer event must have a non-empty new_owner")]
94 TransferNewOwnerEmpty,
95
96 #[error(
98 "governance confirm event name_old_owner cannot be empty if present"
99 )]
100 ConfirmNameOldOwnerEmpty,
101
102 #[error("tracker confirm event must not have name_old_owner")]
104 ConfirmTrackerNameOldOwner,
105
106 #[error("subject data not found for subject '{0}'")]
108 SubjectDataNotFound(String),
109
110 #[error("subject '{0}' is not active")]
112 SubjectNotActive(String),
113
114 #[error("creation events cannot be queued")]
116 CreationNotQueued,
117
118 #[error("failed to compute request_id: {0}")]
120 RequestIdHash(String),
121
122 #[error("failed to compute subject_id: {0}")]
124 SubjectIdHash(String),
125
126 #[error("request signature verification failed: {0}")]
128 SignatureVerification(String),
129
130 #[error("actor error: {0}")]
132 Actor(#[from] ActorError),
133}
134
135impl From<RequestHandlerError> for ActorError {
136 fn from(err: RequestHandlerError) -> Self {
137 match err {
138 RequestHandlerError::HelpersNotInitialized => {
139 Self::FunctionalCritical {
140 description: err.to_string(),
141 }
142 }
143 RequestHandlerError::Actor(e) => e,
144 _ => Self::Functional {
145 description: err.to_string(),
146 },
147 }
148 }
149}
150
151#[derive(Debug, Error, Clone)]
152pub enum RequestManagerError {
153 #[error(
154 "the subject could not be created; the maximum limit has been reached."
155 )]
156 CheckLimit,
157 #[error("request is not set")]
159 RequestNotSet,
160
161 #[error("helpers (hash algorithm and network sender) are not initialized")]
162 HelpersNotInitialized,
163
164 #[error("invalid request state: expected {expected}, got {got}")]
165 InvalidRequestState {
166 expected: &'static str,
167 got: &'static str,
168 },
169
170 #[error("only Fact, Transfer and Confirm requests can be evaluated")]
172 InvalidEventRequestForEvaluation,
173
174 #[error("Confirm events on tracker subjects cannot be evaluated")]
175 ConfirmNotEvaluableForTracker,
176
177 #[error("no evaluators available for schema '{schema_id}'")]
179 NoEvaluatorsAvailable {
180 schema_id: String,
181 governance_id: DigestIdentifier,
182 },
183
184 #[error("no approvers available for schema '{schema_id}'")]
185 NoApproversAvailable {
186 schema_id: String,
187 governance_id: DigestIdentifier,
188 },
189
190 #[error("no validators available for schema '{schema_id}'")]
191 NoValidatorsAvailable {
192 schema_id: String,
193 governance_id: DigestIdentifier,
194 },
195
196 #[error(
197 "governance version changed for '{governance_id}': expected {expected}, got {current}"
198 )]
199 GovernanceVersionChanged {
200 governance_id: DigestIdentifier,
201 expected: u64,
202 current: u64,
203 },
204
205 #[error("governance error: {0}")]
207 Governance(#[from] GovernanceError),
208
209 #[error("subject data not found for subject '{subject_id}'")]
211 SubjectDataNotFound { subject_id: String },
212
213 #[error("last ledger event not found for subject")]
214 LastLedgerEventNotFound,
215
216 #[error("failed to compute ledger hash: {details}")]
217 LedgerHashFailed { details: String },
218
219 #[error("failed to build protocols: {0}")]
221 ProtocolsBuild(#[from] ProtocolsError),
222
223 #[error("ledger error: {0}")]
224 Ledger(#[from] LedgerError),
225
226 #[error("actor error: {0}")]
228 ActorError(#[from] ActorError),
229
230 #[error("Can not obtain SubjectData, is None")]
231 SubjecData,
232
233 #[error("In fact events, the signer has to be an issuer")]
234 NotIssuer,
235
236 #[error("In create tracker events, the signer has to be a creator")]
237 NotCreator,
238}
239
240