ave_core/subject/
error.rs1use thiserror::Error;
2
3#[derive(Debug, Error, Clone)]
4pub enum SubjectError {
5 #[error("subject is no longer active")]
7 SubjectInactive,
8
9 #[error("subject schema id is invalid")]
10 InvalidSchemaId,
11
12 #[error("signature verification failed: {context}")]
14 SignatureVerificationFailed { context: String },
15
16 #[error("incorrect signer: expected {expected}, got {actual}")]
17 IncorrectSigner { expected: String, actual: String },
18
19 #[error(
20 "event request signer is invalid for {event}: expected {expected}, got {actual}"
21 )]
22 InvalidEventRequestSigner {
23 event: String,
24 expected: String,
25 actual: String,
26 },
27
28 #[error("validation request signature is invalid")]
29 InvalidValidationRequestSignature,
30
31 #[error("validator signature could not be verified")]
32 InvalidValidatorSignature,
33
34 #[error(
36 "event is not the next one to be applied: expected sn {expected}, got {actual}"
37 )]
38 InvalidSequenceNumber { expected: u64, actual: u64 },
39
40 #[error("previous ledger event hash does not match")]
41 PreviousHashMismatch,
42
43 #[error("subject id mismatch: expected {expected}, got {actual}")]
44 SubjectIdMismatch { expected: String, actual: String },
45
46 #[error("ledger event hash mismatch: expected {expected}, got {actual}")]
47 LedgerHashMismatch { expected: String, actual: String },
48
49 #[error("event type does not match protocols")]
50 EventProtocolMismatch,
51
52 #[error("event should be {expected} but got {actual}")]
53 UnexpectedEventType { expected: String, actual: String },
54
55 #[error("fact event received but should be confirm or reject event")]
57 UnexpectedFactEvent,
58
59 #[error("transfer event received but should be confirm or reject event")]
60 UnexpectedTransferEvent,
61
62 #[error("EOL event received but should be confirm or reject event")]
63 UnexpectedEOLEvent,
64
65 #[error("confirm event received but new_owner is None")]
66 ConfirmWithoutNewOwner,
67
68 #[error("reject event received but new_owner is None")]
69 RejectWithoutNewOwner,
70
71 #[error("quorum is not valid")]
73 InvalidQuorum,
74
75 #[error("validation request hash does not match")]
76 ValidationRequestHashMismatch,
77
78 #[error("validators and quorum could not be obtained: {details}")]
79 ValidatorsRetrievalFailed { details: String },
80
81 #[error("event metadata does not match subject metadata")]
83 MetadataMismatch,
84
85 #[error("validation metadata must be of type Metadata in creation event")]
86 InvalidValidationMetadata,
87
88 #[error(
89 "validation metadata must be of type ModifiedMetadataHash in non-creation event"
90 )]
91 InvalidNonCreationValidationMetadata,
92
93 #[error("in creation event, sequence number must be 0")]
94 InvalidCreationSequenceNumber,
95
96 #[error("previous ledger event hash must be empty in creation event")]
97 NonEmptyPreviousHashInCreation,
98
99 #[error("failed to apply patch: {details}")]
101 PatchApplicationFailed { details: String },
102
103 #[error("failed to convert ValueWrapper into Patch: {details}")]
104 PatchConversionFailed { details: String },
105
106 #[error("evaluation was satisfactory but there was no approval")]
107 MissingApprovalAfterEvaluation,
108
109 #[error("evaluation was not satisfactory but there is approval")]
110 UnexpectedApprovalAfterFailedEvaluation,
111
112 #[error("failed to convert properties into GovernanceData: {details}")]
114 GovernanceDataConversionFailed { details: String },
115
116 #[error(
117 "schema_id is Governance, but cannot convert properties: {details}"
118 )]
119 GovernancePropertiesConversionFailed { details: String },
120
121 #[error("{what} '{who}' is not a member")]
122 NotAMember { what: String, who: String },
123
124 #[error("schema '{schema_id}' has no policies")]
125 SchemaNoPolicies { schema_id: String },
126
127 #[error("schema '{schema_id}' is not a schema")]
128 InvalidSchema { schema_id: String },
129
130 #[error("number of subjects that can be created has not been found")]
132 MaxSubjectCreationNotFound,
133
134 #[error("protocols data is for Governance but this is a Tracker")]
135 GovernanceProtocolsInTracker,
136
137 #[error("protocols data is for Tracker but this is a Governance")]
138 TrackerProtocolsInGovernance,
139
140 #[error("node configured for clear events cannot accept tracker opaque events")]
141 OnlyClearEventsCannotAcceptTrackerOpaque,
142
143 #[error("governance fact event cannot contain viewpoints")]
144 GovernanceFactViewpointsNotAllowed,
145
146 #[error("failed to create hash: {details}")]
148 HashCreationFailed { details: String },
149
150 #[error("validation request hash could not be obtained: {details}")]
151 ValidationRequestHashFailed { details: String },
152
153 #[error("modified metadata hash could not be obtained: {details}")]
154 ModifiedMetadataHashFailed { details: String },
155
156 #[error(
157 "modified metadata without properties hash mismatch: expected {expected}, got {actual}"
158 )]
159 ModifiedMetadataWithoutPropertiesHashMismatch {
160 expected: String,
161 actual: String,
162 },
163
164 #[error("properties hash mismatch: expected {expected}, got {actual}")]
165 PropertiesHashMismatch { expected: String, actual: String },
166
167 #[error("event request hash mismatch: expected {expected}, got {actual}")]
168 EventRequestHashMismatch { expected: String, actual: String },
169
170 #[error("viewpoints hash mismatch: expected {expected}, got {actual}")]
171 ViewpointsHashMismatch { expected: String, actual: String },
172
173 #[error("actor not found: {path}")]
175 ActorNotFound { path: String },
176
177 #[error("unexpected response from {path}: expected {expected}")]
178 UnexpectedResponse { path: String, expected: String },
179
180 #[error("helper not found: {helper}")]
181 HelperNotFound { helper: String },
182
183 #[error("cannot obtain {what}")]
184 CannotObtain { what: String },
185
186 #[error("{0}")]
188 Generic(String),
189}
190
191impl From<String> for SubjectError {
192 fn from(s: String) -> Self {
193 Self::Generic(s)
194 }
195}
196
197impl From<&str> for SubjectError {
198 fn from(s: &str) -> Self {
199 Self::Generic(s.to_string())
200 }
201}