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("validation request signature is invalid")]
20 InvalidValidationRequestSignature,
21
22 #[error("validator signature could not be verified")]
23 InvalidValidatorSignature,
24
25 #[error(
27 "event is not the next one to be applied: expected sn {expected}, got {actual}"
28 )]
29 InvalidSequenceNumber { expected: u64, actual: u64 },
30
31 #[error("previous ledger event hash does not match")]
32 PreviousHashMismatch,
33
34 #[error("ledger event hash mismatch: expected {expected}, got {actual}")]
35 LedgerHashMismatch { expected: String, actual: String },
36
37 #[error("event type does not match protocols")]
38 EventProtocolMismatch,
39
40 #[error("event should be {expected} but got {actual}")]
41 UnexpectedEventType { expected: String, actual: String },
42
43 #[error("fact event received but should be confirm or reject event")]
45 UnexpectedFactEvent,
46
47 #[error("transfer event received but should be confirm or reject event")]
48 UnexpectedTransferEvent,
49
50 #[error("EOL event received but should be confirm or reject event")]
51 UnexpectedEOLEvent,
52
53 #[error("confirm event received but new_owner is None")]
54 ConfirmWithoutNewOwner,
55
56 #[error("reject event received but new_owner is None")]
57 RejectWithoutNewOwner,
58
59 #[error("quorum is not valid")]
61 InvalidQuorum,
62
63 #[error("validation request hash does not match")]
64 ValidationRequestHashMismatch,
65
66 #[error("validators and quorum could not be obtained: {details}")]
67 ValidatorsRetrievalFailed { details: String },
68
69 #[error("event metadata does not match subject metadata")]
71 MetadataMismatch,
72
73 #[error("validation metadata must be of type Metadata in creation event")]
74 InvalidValidationMetadata,
75
76 #[error("in creation event, sequence number must be 0")]
77 InvalidCreationSequenceNumber,
78
79 #[error("previous ledger event hash must be empty in creation event")]
80 NonEmptyPreviousHashInCreation,
81
82 #[error("failed to apply patch: {details}")]
84 PatchApplicationFailed { details: String },
85
86 #[error("failed to convert ValueWrapper into Patch: {details}")]
87 PatchConversionFailed { details: String },
88
89 #[error("evaluation was satisfactory but there was no approval")]
90 MissingApprovalAfterEvaluation,
91
92 #[error("evaluation was not satisfactory but there is approval")]
93 UnexpectedApprovalAfterFailedEvaluation,
94
95 #[error("failed to convert properties into GovernanceData: {details}")]
97 GovernanceDataConversionFailed { details: String },
98
99 #[error(
100 "schema_id is Governance, but cannot convert properties: {details}"
101 )]
102 GovernancePropertiesConversionFailed { details: String },
103
104 #[error("{what} '{who}' is not a member")]
105 NotAMember { what: String, who: String },
106
107 #[error("schema '{schema_id}' has no policies")]
108 SchemaNoPolicies { schema_id: String },
109
110 #[error("schema '{schema_id}' is not a schema")]
111 InvalidSchema { schema_id: String },
112
113 #[error("number of subjects that can be created has not been found")]
115 MaxSubjectCreationNotFound,
116
117 #[error("protocols data is for Governance but this is a Tracker")]
118 GovernanceProtocolsInTracker,
119
120 #[error("protocols data is for Tracker but this is a Governance")]
121 TrackerProtocolsInGovernance,
122
123 #[error("failed to create hash: {details}")]
125 HashCreationFailed { details: String },
126
127 #[error("validation request hash could not be obtained: {details}")]
128 ValidationRequestHashFailed { details: String },
129
130 #[error("modified metadata hash could not be obtained: {details}")]
131 ModifiedMetadataHashFailed { details: String },
132
133 #[error("actor not found: {path}")]
135 ActorNotFound { path: String },
136
137 #[error("unexpected response from {path}: expected {expected}")]
138 UnexpectedResponse { path: String, expected: String },
139
140 #[error("helper not found: {helper}")]
141 HelperNotFound { helper: String },
142
143 #[error("cannot obtain {what}")]
144 CannotObtain { what: String },
145
146 #[error("{0}")]
148 Generic(String),
149}
150
151impl From<String> for SubjectError {
152 fn from(s: String) -> Self {
153 Self::Generic(s)
154 }
155}
156
157impl From<&str> for SubjectError {
158 fn from(s: &str) -> Self {
159 Self::Generic(s.to_string())
160 }
161}