ave_core/request/
error.rs1use ave_actors::ActorError;
2use ave_common::identity::DigestIdentifier;
3use thiserror::Error;
4
5use crate::{governance::error::GovernanceError, model::event::ProtocolsError};
6
7#[derive(Debug, Error, Clone)]
8pub enum RequestHandlerError {
9 #[error("helpers are not initialized")]
11 HelpersNotInitialized,
12
13 #[error("the payload cannot be deserialized as a governance event")]
14 GovFactInvalidEvent,
15
16 #[error("a user cannot mark a request approval as obsolete")]
18 ObsoleteApproval,
19
20 #[error(
22 "no approval found for subject '{0}', node likely no longer has approver role"
23 )]
24 ApprovalNotFound(String),
25
26 #[error("failed to change approval state")]
28 ApprovalChangeFailed,
29
30 #[error("failed to get approval state")]
32 ApprovalGetFailed,
33
34 #[error("not the owner of subject '{0}'")]
36 NotOwner(String),
37
38 #[error("subject '{0}' has a pending new owner")]
40 PendingNewOwner(String),
41
42 #[error("signer is the owner of subject '{0}', cannot confirm/reject")]
44 IsOwner(String),
45
46 #[error("signer is not the new owner of subject '{0}'")]
48 NotNewOwner(String),
49
50 #[error("no new owner pending for subject '{0}'")]
52 NoNewOwnerPending(String),
53
54 #[error("subject name must be between 1 and 100 characters")]
56 InvalidName,
57
58 #[error("subject description must be between 1 and 200 characters")]
60 InvalidDescription,
61
62 #[error("invalid schema_id in request")]
64 InvalidSchemaId,
65
66 #[error("governance creation must have empty governance_id")]
68 GovernanceIdMustBeEmpty,
69
70 #[error("governance creation must have empty namespace")]
72 NamespaceMustBeEmpty,
73
74 #[error("non-governance creation must have a governance_id")]
76 GovernanceIdRequired,
77
78 #[error("transfer event must have a non-empty new_owner")]
80 TransferNewOwnerEmpty,
81
82 #[error(
84 "governance confirm event name_old_owner cannot be empty if present"
85 )]
86 ConfirmNameOldOwnerEmpty,
87
88 #[error("tracker confirm event must not have name_old_owner")]
90 ConfirmTrackerNameOldOwner,
91
92 #[error("subject data not found for subject '{0}'")]
94 SubjectDataNotFound(String),
95
96 #[error("subject '{0}' is not active")]
98 SubjectNotActive(String),
99
100 #[error("creation events cannot be queued")]
102 CreationNotQueued,
103
104 #[error("failed to compute request_id: {0}")]
106 RequestIdHash(String),
107
108 #[error("failed to compute subject_id: {0}")]
110 SubjectIdHash(String),
111
112 #[error("request signature verification failed: {0}")]
114 SignatureVerification(String),
115
116 #[error("actor error: {0}")]
118 Actor(#[from] ActorError),
119}
120
121impl From<RequestHandlerError> for ActorError {
122 fn from(err: RequestHandlerError) -> Self {
123 match err {
124 RequestHandlerError::HelpersNotInitialized => {
125 Self::FunctionalCritical {
126 description: err.to_string(),
127 }
128 }
129 RequestHandlerError::Actor(e) => e,
130 _ => Self::Functional {
131 description: err.to_string(),
132 },
133 }
134 }
135}
136
137#[derive(Debug, Error, Clone)]
138pub enum RequestManagerError {
139 #[error(
140 "the subject could not be created; the maximum limit has been reached."
141 )]
142 CheckLimit,
143 #[error("request is not set")]
145 RequestNotSet,
146
147 #[error("helpers (hash algorithm and network sender) are not initialized")]
148 HelpersNotInitialized,
149
150 #[error("invalid request state: expected {expected}, got {got}")]
151 InvalidRequestState {
152 expected: &'static str,
153 got: &'static str,
154 },
155
156 #[error("only Fact, Transfer and Confirm requests can be evaluated")]
158 InvalidEventRequestForEvaluation,
159
160 #[error("Confirm events on tracker subjects cannot be evaluated")]
161 ConfirmNotEvaluableForTracker,
162
163 #[error("no evaluators available for schema '{schema_id}'")]
165 NoEvaluatorsAvailable {
166 schema_id: String,
167 governance_id: DigestIdentifier,
168 },
169
170 #[error("no approvers available for schema '{schema_id}'")]
171 NoApproversAvailable {
172 schema_id: String,
173 governance_id: DigestIdentifier,
174 },
175
176 #[error("no validators available for schema '{schema_id}'")]
177 NoValidatorsAvailable {
178 schema_id: String,
179 governance_id: DigestIdentifier,
180 },
181
182 #[error("governance error: {0}")]
184 Governance(#[from] GovernanceError),
185
186 #[error("subject data not found for subject '{subject_id}'")]
188 SubjectDataNotFound { subject_id: String },
189
190 #[error("last ledger event not found for subject")]
191 LastLedgerEventNotFound,
192
193 #[error("failed to compute ledger hash: {details}")]
194 LedgerHashFailed { details: String },
195
196 #[error("failed to build protocols: {0}")]
198 ProtocolsBuild(#[from] ProtocolsError),
199
200 #[error("actor error: {0}")]
202 ActorError(#[from] ActorError),
203
204 #[error("Can not obtain SubjectData, is None")]
205 SubjecData,
206
207 #[error("In fact events, the signer has to be an issuer")]
208 NotIssuer,
209}
210
211