Skip to main content

troupekit_local/
error.rs

1/// Every failure of an on-device model: load, tokenize, decode, context
2/// size, grammar, unsupported operations, the model cache and catalog.
3/// Messages name the cause and never hold prompt or reply text.
4/// `LocalChat` maps these to `ProviderErrorKind::Server` with this text.
5#[derive(Debug, Clone, PartialEq, thiserror::Error)]
6#[non_exhaustive]
7pub enum LocalError {
8    #[error("local model load failed: {0}")]
9    Load(String),
10    #[error("local tokenize failed: {0}")]
11    Tokenize(String),
12    #[error("local decode failed: {0}")]
13    Decode(String),
14    #[error("local context full: {needed} tokens needed, limit {limit}")]
15    ContextFull { needed: usize, limit: usize },
16    #[error("local grammar refused: {0}")]
17    Grammar(String),
18    #[error("local model does not support {0}")]
19    Unsupported(&'static str),
20    #[error("local model cache: {0}")]
21    Cache(String),
22    #[error("local model catalog: {0}")]
23    Catalog(String),
24}