1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum ClaimLedgerError {
8 #[error("claim not found: {0}")]
10 ClaimNotFound(String),
11
12 #[error("support judgment not found: {0}")]
14 SupportJudgmentNotFound(String),
15
16 #[error("evidence bundle not found: {0}")]
18 EvidenceBundleNotFound(String),
19
20 #[error("contradiction not found: {0}")]
22 ContradictionNotFound(String),
23
24 #[error("invalid support state transition: {0}")]
26 InvalidSupportTransition(String),
27
28 #[error("supported admission requires proof payload or proof debt waiver")]
30 MissingProofPayload,
31
32 #[error("ledger verification failed: {0}")]
34 LedgerCorrupt(String),
35
36 #[error("serialization error: {0}")]
38 SerializationError(String),
39
40 #[error("missing required input reference: {0}")]
42 MissingInputRef(String),
43}
44
45impl ClaimLedgerError {
46 pub fn kind(&self) -> &'static str {
48 match self {
49 Self::ClaimNotFound(_) => "claim_not_found",
50 Self::SupportJudgmentNotFound(_) => "support_judgment_not_found",
51 Self::EvidenceBundleNotFound(_) => "evidence_bundle_not_found",
52 Self::ContradictionNotFound(_) => "contradiction_not_found",
53 Self::InvalidSupportTransition(_) => "invalid_support_transition",
54 Self::MissingProofPayload => "missing_proof_payload",
55 Self::LedgerCorrupt(_) => "ledger_corrupt",
56 Self::SerializationError(_) => "serialization_error",
57 Self::MissingInputRef(_) => "missing_input_ref",
58 }
59 }
60}