arpa_dal/
error.rs

1use arpa_core::BLSTaskError;
2use thiserror::Error;
3
4pub type DataAccessResult<A> = Result<A, DataAccessError>;
5
6#[derive(Debug, Error)]
7pub enum DataAccessError {
8    #[error(transparent)]
9    NodeInfoError(#[from] NodeInfoError),
10
11    #[error(transparent)]
12    GroupError(#[from] GroupError),
13
14    #[error(transparent)]
15    RandomnessTaskError(#[from] RandomnessTaskError),
16
17    #[error(transparent)]
18    TaskError(#[from] BLSTaskError),
19
20    #[error(transparent)]
21    DBError(anyhow::Error),
22
23    #[error("the chain id: {0} is not supported")]
24    InvalidChainId(usize),
25
26    #[error("could not deserialize: {0}")]
27    DeserializationError(#[from] bincode::Error),
28}
29
30#[derive(Debug, Error, PartialEq)]
31pub enum GroupError {
32    #[error("there is no group task yet")]
33    NoGroupTask,
34
35    #[error("the group is not exist")]
36    GroupNotExisted,
37
38    #[error("the member is not exist")]
39    MemberNotExisted,
40
41    #[error("there is not an available DKG output")]
42    GroupNotReady,
43
44    #[error("there is already an available DKG setup")]
45    GroupAlreadyReady,
46
47    #[error("the group index is different from the latest: {0}")]
48    GroupIndexObsolete(usize),
49
50    #[error("the group epoch is different from the latest: {0}")]
51    GroupEpochObsolete(usize),
52
53    #[error("the group is still waiting for other's DKGOutput to commit")]
54    GroupWaitingForConsensus,
55}
56
57#[derive(Debug, Error, PartialEq)]
58pub enum NodeInfoError {
59    #[error("there is no rpc endpoint yet")]
60    NoRpcEndpoint,
61
62    #[error("there is no dkg key pair yet")]
63    NoDKGKeyPair,
64}
65
66#[derive(Debug, Error, PartialEq)]
67pub enum RandomnessTaskError {
68    #[error("there is no randomness task with request id:{0}")]
69    NoRandomnessTask(String),
70}