Skip to main content

laya/
error.rs

1use thiserror::Error;
2
3/// Errors surfaced by the Laya engine.
4#[derive(Debug, Error)]
5pub enum LayaError {
6    /// A question definition is malformed. The message names the question and what to fix,
7    /// matching the Python `Agent._check_question` diagnostics.
8    #[error("{0}")]
9    InvalidQuestion(String),
10
11    /// A checkpoint config / architecture problem.
12    #[error("{0}")]
13    Config(String),
14
15    /// A required file or resource was not found.
16    #[error("{0}")]
17    NotFound(String),
18
19    /// Tokenizer construction or encoding failure.
20    #[error("tokenizer error: {0}")]
21    Tokenizer(String),
22
23    /// Model construction or inference failure.
24    #[error("model error: {0}")]
25    Model(String),
26
27    /// Hugging Face Hub download failure.
28    #[error("download error: {0}")]
29    Download(String),
30
31    #[error(transparent)]
32    Io(#[from] std::io::Error),
33
34    #[error(transparent)]
35    Json(#[from] serde_json::Error),
36}
37
38pub type Result<T> = std::result::Result<T, LayaError>;