Skip to main content

sightloom_host/
error.rs

1//! Host package errors.
2
3use core::fmt;
4
5/// Errors from host model config, registry, preprocess, or adapters.
6#[derive(Clone, Debug, PartialEq, Eq)]
7pub enum HostError {
8    /// Invalid configuration.
9    Config(String),
10    /// Model file / registry path missing.
11    ModelNotFound(String),
12    /// Preprocess failure.
13    Preprocess(String),
14    /// Adapter / runtime failure.
15    Runtime(String),
16    /// Download not available or failed (step 2+).
17    Download(String),
18    /// Weight integrity check failed (SHA-256 mismatch).
19    Integrity(String),
20    /// I/O failure.
21    Io(String),
22}
23
24impl fmt::Display for HostError {
25    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
26        match self {
27            Self::Config(m) => write!(f, "host config: {m}"),
28            Self::ModelNotFound(m) => write!(f, "model not found: {m}"),
29            Self::Preprocess(m) => write!(f, "preprocess: {m}"),
30            Self::Runtime(m) => write!(f, "runtime: {m}"),
31            Self::Download(m) => write!(f, "download: {m}"),
32            Self::Integrity(m) => write!(f, "integrity: {m}"),
33            Self::Io(m) => write!(f, "io: {m}"),
34        }
35    }
36}
37
38impl std::error::Error for HostError {}