1use grovedb::query_result_type::Path;
2
3#[derive(Debug, thiserror::Error)]
5pub enum ProofError {
6 #[error("too many elements error: {0}")]
8 TooManyElements(&'static str),
9
10 #[error("wrong element count error expected: {expected} got: {got}")]
12 WrongElementCount {
13 expected: usize,
15 got: usize,
17 },
18
19 #[error("overflow error: {0}")]
21 Overflow(&'static str),
22
23 #[error("corrupted error: {0}")]
26 CorruptedProof(String),
27
28 #[error("incorrect proof error: {0}")]
31 IncorrectProof(String),
32
33 #[error("unexpected result in proof error: {0}")]
38 UnexpectedResultProof(String),
39
40 #[error("invalid transition error: {0}")]
42 InvalidTransition(String),
43
44 #[error("unknown contract in documents batch transition error: {0}")]
46 UnknownContract(String),
47
48 #[error("invalid metadata: {0}")]
50 InvalidMetadata(String),
51
52 #[error("the contract could not be retrieved during verification: {0}")]
54 ErrorRetrievingContract(String),
55
56 #[error("missing context requirement error: {0}")]
58 MissingContextRequirement(String),
59
60 #[error("incomplete proof error: {0}")]
62 IncompleteProof(&'static str),
63
64 #[error("incorrect value size error: {0}")]
66 IncorrectValueSize(&'static str),
67
68 #[error("incorrect element path error")]
70 IncorrectElementPath {
71 expected: Path,
73 actual: Path,
75 },
76
77 #[error("invalid GroveDB proof envelope in the {proof}: {reason}")]
79 InvalidGroveDBProofEnvelope {
80 proof: &'static str,
82 reason: String,
84 },
85
86 #[error(
90 "unsupported GroveDB proof envelope version {version} in the {proof}: protocol version {protocol_version} requires at least version {minimum}"
91 )]
92 UnsupportedGroveDBProofEnvelopeVersion {
93 proof: &'static str,
95 version: u32,
97 minimum: u32,
99 protocol_version: u32,
101 },
102}
103#[allow(dead_code)]
104#[deprecated(note = "This function is marked as unused.")]
105#[allow(deprecated)]
106fn get_error_code(error: &ProofError) -> u32 {
107 match error {
108 ProofError::TooManyElements(_) => 6000,
109 ProofError::WrongElementCount { .. } => 6001,
110 ProofError::Overflow(_) => 6002,
111 ProofError::CorruptedProof(_) => 6003,
112 ProofError::IncompleteProof(_) => 6004,
113 ProofError::IncorrectValueSize(_) => 6005,
114 ProofError::IncorrectElementPath { .. } => 6006,
115 ProofError::IncorrectProof(_) => 6007,
116 ProofError::InvalidTransition(_) => 6008,
117 ProofError::UnknownContract(_) => 6009,
118 ProofError::ErrorRetrievingContract(_) => 6010,
119 ProofError::InvalidMetadata(_) => 6011,
120 ProofError::MissingContextRequirement(_) => 6012,
121 ProofError::UnexpectedResultProof(_) => 6013,
122 ProofError::InvalidGroveDBProofEnvelope { .. } => 6014,
123 ProofError::UnsupportedGroveDBProofEnvelopeVersion { .. } => 6015,
124 }
125}