Skip to main content

hoike_core/
error.rs

1use std::path::PathBuf;
2
3use thiserror::Error;
4
5#[derive(Debug, Error)]
6pub enum CoreError {
7    #[error("empty OCSP request")]
8    EmptyRequest,
9
10    #[error("request too large: {size} bytes (max {max})")]
11    RequestTooLarge { size: usize, max: usize },
12
13    #[error("empty request list in OCSPRequest")]
14    EmptyRequestList,
15
16    #[error("DER parse error in {context}: {detail}")]
17    DerParse {
18        context: &'static str,
19        detail: String,
20    },
21
22    #[error("GET path decode error: {0}")]
23    GetDecode(String),
24
25    #[error("no matching CA scope for CertID")]
26    NoMatchingScope,
27
28    #[error("bundle error: {0}")]
29    Bundle(#[from] ahu::AhuError),
30
31    #[error("configuration error: {0}")]
32    Config(String),
33
34    #[error("epoch rollback: scope {scope} epoch {epoch} <= high-water {high_water}")]
35    EpochRollback {
36        scope: String,
37        epoch: u64,
38        high_water: u64,
39    },
40
41    #[error(
42        "epoch jump too large: scope {scope} epoch {epoch} jumps {jump} from high-water {high_water} (max allowed: {max_jump})"
43    )]
44    EpochJumpTooLarge {
45        scope: String,
46        epoch: u64,
47        high_water: u64,
48        jump: u64,
49        max_jump: u64,
50    },
51
52    #[error("fork detected: prev_manifest_digest mismatch for scope {scope}")]
53    ForkDetected { scope: String },
54
55    #[error("state store error: {0}")]
56    StateStore(String),
57
58    #[error("state directory lock error: {0}")]
59    StateLock(String),
60
61    #[error(
62        "durability uncertain after replacing {path}: {reason}. The replacement may or may not \
63         survive a crash — stop writers, inspect the persisted descriptor, and reopen state \
64         before continuing; do not assume the previous generation was preserved"
65    )]
66    DurabilityUncertain { path: PathBuf, reason: String },
67
68    #[error("I/O error: {0}")]
69    Io(#[from] std::io::Error),
70}
71
72pub type Result<T> = std::result::Result<T, CoreError>;