1use thiserror::Error;
2
3#[derive(Debug, Error)]
6pub enum KuteError {
7 #[error("invalid input: {0}")]
8 InvalidInput(String),
9 #[error("invalid vocabulary: {0}")]
10 InvalidVocabulary(String),
11 #[error("invalid identifier: {0}")]
12 InvalidIdentifier(String),
13 #[error("invalid configuration: {0}")]
14 InvalidConfig(String),
15 #[error("unknown token id {0}")]
16 UnknownToken(u32),
17 #[error("unknown symbol {0:?}: it is not in the vocabulary and this vocabulary has no lossless fallback for it")]
18 UnknownSymbol(String),
19 #[error("vocabulary mismatch: {0}")]
20 VocabularyMismatch(String),
21 #[error("unsupported: {0}")]
22 Unsupported(String),
23 #[error("tokenizer has no vocabulary: {0}")]
24 NotTrained(String),
25 #[error("limit exceeded: {0}")]
26 LimitExceeded(String),
27 #[error("integrity check failed: {0}")]
28 Integrity(String),
29 #[error("i/o error: {0}")]
30 Io(#[from] std::io::Error),
31 #[error("serialization error: {0}")]
32 Serde(String),
33 #[error("backend error: {0}")]
34 Backend(String),
35}
36
37impl From<serde_json::Error> for KuteError {
38 fn from(e: serde_json::Error) -> Self {
39 KuteError::Serde(e.to_string())
40 }
41}
42
43pub type Result<T> = std::result::Result<T, KuteError>;