1use ave_actors::ActorError;
2use thiserror::Error;
3
4#[derive(Debug, Error, Clone)]
5pub enum LedgerError {
6 #[error("failed to hash ledger: {0}")]
7 HashingFailed(String),
8
9 #[error("protocols error: {0}")]
10 Protocols(#[from] ProtocolsError),
11}
12
13#[derive(Debug, Error, Clone)]
14pub enum ProtocolsError {
15 #[error(
16 "invalid evaluation: evaluation result does not match expected state"
17 )]
18 InvalidEvaluation,
19
20 #[error("invalid evaluation: approval required but not provided")]
21 ApprovalRequired,
22
23 #[error("invalid actual protocols: expected {expected}, got {got}")]
24 InvalidActualProtocols {
25 expected: &'static str,
26 got: &'static str,
27 },
28
29 #[error(
30 "invalid event request type: {request_type} is not supported for is_gov={is_gov}"
31 )]
32 InvalidEventRequestType {
33 request_type: &'static str,
34 is_gov: bool,
35 },
36
37 #[error(
38 "expected create event with metadata, got different protocol or validation metadata"
39 )]
40 NotCreateWithMetadata,
41
42 #[error("failed to hash protocols: {0}")]
43 HashingFailed(String),
44
45 #[error("tracker fact full requires a fact event request")]
46 InvalidTrackerFactFullEventRequest,
47
48 #[error("only tracker fact events can be projected as opaque")]
49 InvalidTrackerOpaqueProjection,
50}
51
52impl From<ProtocolsError> for ActorError {
53 fn from(error: ProtocolsError) -> Self {
54 Self::Functional {
55 description: error.to_string(),
56 }
57 }
58}
59
60impl From<LedgerError> for ActorError {
61 fn from(error: LedgerError) -> Self {
62 Self::Functional {
63 description: error.to_string(),
64 }
65 }
66}