use std::path::PathBuf;
#[derive(Debug, thiserror::Error)]
pub enum GuardError {
#[error("unknown guard model `{0}`; run `harn guard list` to see available models")]
UnknownModel(String),
#[error(
"`{model}` is gated under {license}: accept the license at {license_url} and set HF_TOKEN, \
then re-run with --accept-license"
)]
Gated {
model: String,
license: String,
license_url: String,
},
#[error(
"installing `{model}` requires accepting its license ({license} — {license_url}); \
pass --accept-license to confirm"
)]
LicenseNotAccepted {
model: String,
license: String,
license_url: String,
},
#[error("integrity check failed for `{file}`: expected {expected}, got {actual}")]
ChecksumMismatch {
file: String,
expected: String,
actual: String,
},
#[error("install payload is missing required file `{0}`")]
MissingFile(String),
#[error("guard model path does not exist: {0}")]
PathNotFound(PathBuf),
#[error("malformed guard manifest at {path}: {source}")]
Manifest {
path: PathBuf,
source: serde_json::Error,
},
#[error("guard store I/O error at {path}: {source}")]
Io {
path: PathBuf,
source: std::io::Error,
},
#[error("guard inference error: {0}")]
Inference(String),
}
pub type Result<T> = std::result::Result<T, GuardError>;