1use std::path::PathBuf;
4
5#[derive(Debug, thiserror::Error)]
7pub enum GuardError {
8 #[error("unknown guard model `{0}`; run `harn guard list` to see available models")]
10 UnknownModel(String),
11
12 #[error(
14 "`{model}` is gated under {license}: accept the license at {license_url} and set HF_TOKEN, \
15 then re-run with --accept-license"
16 )]
17 Gated {
18 model: String,
19 license: String,
20 license_url: String,
21 },
22
23 #[error(
25 "installing `{model}` requires accepting its license ({license} — {license_url}); \
26 pass --accept-license to confirm"
27 )]
28 LicenseNotAccepted {
29 model: String,
30 license: String,
31 license_url: String,
32 },
33
34 #[error("integrity check failed for `{file}`: expected {expected}, got {actual}")]
36 ChecksumMismatch {
37 file: String,
38 expected: String,
39 actual: String,
40 },
41
42 #[error("install payload is missing required file `{0}`")]
44 MissingFile(String),
45
46 #[error("guard model path does not exist: {0}")]
48 PathNotFound(PathBuf),
49
50 #[error("malformed guard manifest at {path}: {source}")]
52 Manifest {
53 path: PathBuf,
54 source: serde_json::Error,
55 },
56
57 #[error("guard store I/O error at {path}: {source}")]
59 Io {
60 path: PathBuf,
61 source: std::io::Error,
62 },
63
64 #[error("guard inference error: {0}")]
66 Inference(String),
67}
68
69pub type Result<T> = std::result::Result<T, GuardError>;