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
use crate::{commons::errors::SubjectError, database::Error as DbError};
use thiserror::Error;

#[derive(Error, Debug, Clone, PartialEq)]
pub enum RequestError {
    #[error("Database Error")]
    DatabaseError(#[from] DbError),
    #[error("Subject Error")]
    SubjectError(#[from] SubjectError),
    #[error("Governance requested not found")]
    GovernanceNotFound(String),
    #[error("Subject requested not found")]
    SubjectNotFound,
    #[error("Schema requested not found")]
    SchemaNotFound(String),
    #[error("JSON Schema compile error")]
    JSONCompileError,
    #[error("Error Parsing Json String")]
    ErrorParsingJsonString(String),
    #[error("Invalid KeyIdentifier {0}")]
    InvalidKeyIdentifier(String),
    #[error("Invalid Name {0}")]
    InvalidName(String),
    #[error("Unexpected response")]
    UnexpectedResponse,
    #[error("Channel Closed")]
    ChannelClosed,
    #[error("Governance version too high: {0}, {1}")]
    GovernanceVersionTooHigh(String, u64),
    #[error("Invalid Request Type")]
    InvalidRequestType,
    #[error("Schema Not Found in policies")]
    SchemaNotFoundInPolicies,
    #[error("The specified governance ID is of a subject")]
    InvalidGovernanceID,
    #[error("Unexpect Payload")]
    UnexpectedPayloadType,
    #[error("Searching signers quorum in wrong stage")]
    SearchingSignersQuorumInWrongStage(String),
    #[error("Searching invoke info in wrong stage")]
    SearchingInvokeInfoInWrongStage(String),
}

#[derive(Error, Debug)]
pub enum InternalError {
    #[error("Channel unnavaible")]
    ChannelError {
        #[from]
        source: crate::commons::errors::ChannelErrors,
    },
    #[error("Response Oneshot closed")]
    OneshotClosed,
    #[error("Deserialization error")]
    DeserializationError,
    #[error("Invalid KeyIdentifier: {0}")]
    InvalidGovernancePayload(String),
    #[error("Database error: {}", source)]
    DatabaseError {
        #[from]
        source: DbError,
    },
    #[error("Base 64 decode error")]
    Base64DecodingError,
}