1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
use crate::database::Error as DbError;
use crate::{commons::errors::SubjectError, governance::error::RequestError};
use thiserror::Error;

#[derive(Error, Debug, Clone)]
pub enum LedgerError {
    #[error("A channel has been closed")]
    ChannelClosed,
    #[error("Unexpected response")]
    UnexpectedResponse,
    #[error("Subject Not Found: {0}")]
    SubjectNotFound(String),
    #[error("Unexpected transfer received")]
    UnexpectedTransfer,
    #[error("Error parsing json string: \"{0}\"")]
    ErrorParsingJsonString(String),
    #[error("Error applying patch: \"{0}\"")]
    ErrorApplyingPatch(String),
    #[error("State Event entered as Genesis")]
    StateInGenesis,
    #[error("Channel unnavaible")]
    ChannelError(#[from] crate::commons::errors::ChannelErrors),
    #[error("Subject Error")]
    SubjectError(#[from] SubjectError),
    #[error("Crypto Error: \"{0}\"")]
    CryptoError(String),
    #[error("Subject ALready Exists: \"{0}\"")]
    SubjectAlreadyExists(String),
    #[error("Governance Error")]
    GovernanceError(#[from] RequestError),
    #[error("Database Error")]
    DatabaseError(#[from] DbError),
    #[error("Event Already Exists")]
    EventAlreadyExists,
    #[error("Unauthorized: {0}")]
    Unauthorized(String),
    #[error("Not Enough Signatures: {0}")]
    NotEnoughSignatures(String),
    #[error("0 events for subject: {0}")]
    ZeroEventsSubject(String),
    #[error("Wrong SN in Subject: {0}")]
    WrongSnInSubject(String),
    #[error("LCE bigger than last LCE, so we ignore it")]
    LCEBiggerSN,
    #[error("Unsigned Unknown Event")]
    UnsignedUnknowEvent,
    #[error("Unsigned Unknown Event")]
    UnexpectEventMissingInEventSourcing,
    #[error("Event Not Next")]
    EventNotNext,
    #[error("Event Does Not Fit Hash")]
    EventDoesNotFitHash,
    #[error("We are not witnesses: {0}")]
    WeAreNotWitnesses(String),
    #[error("Invalid LCE After Genesis: {0}")]
    InvalidLCEAfterGenesis(String),
    #[error("Governance Not Preauthorized: {0}")]
    GovernanceNotPreauthorized(String),
    #[error("Governance LCE: {0}")]
    GovernanceLCE(String),
    #[error("Evaluation found in Transfer Event")]
    EvaluationInTransferEvent,
    #[error("Approval found in transfer event")]
    ApprovalInTransferEvent,
    #[error("State event with an SN of 0 detected")]
    StateEventWithZeroSNDetected,
    #[error("Unexpected create event")]
    UnexpectedCreateEvent,
    #[error("Validation Proof Error: {0}")]
    ValidationProofError(String),
    #[error("EOL when active LCE for subject: {0}")]
    EOLWhenActiveLCE(String),
    #[error("Intermediate EOL for subject: {0}")]
    IntermediateEOL(String),
    #[error("Subject Life Ended: {0}")]
    SubjectLifeEnd(String),
    #[error("Repeated Request ID: {0}")]
    RepeatedRequestId(String),
    #[error("Subject Id generation does not match with event subject_id")]
    SubjectIdError,
    #[error("Notification Channel Error")]
    NotificationChannelError,
}