autoagents_onnx/
error.rs

1//! Error types for autoagents-onnx runtime
2
3use thiserror::Error;
4
5/// Result type for autoagents-onnx operations
6pub type EdgeResult<T> = Result<T, EdgeError>;
7
8/// Main error type for autoagents-onnx runtime
9#[derive(Error, Debug)]
10pub enum EdgeError {
11    #[error("Model error: {0}")]
12    Model(String),
13
14    #[error("Inference error: {0}")]
15    Inference(String),
16
17    #[error("Tokenizer error: {0}")]
18    Tokenizer(String),
19
20    #[error("Configuration error: {0}")]
21    Config(String),
22
23    #[error("I/O error: {0}")]
24    Io(#[from] std::io::Error),
25
26    #[error("JSON error: {0}")]
27    Json(#[from] serde_json::Error),
28
29    #[error("ONNX Runtime error: {0}")]
30    OnnxRuntime(#[from] ort::Error),
31
32    #[error("Runtime error: {0}")]
33    Runtime(String),
34}
35
36impl EdgeError {
37    pub fn model(msg: impl Into<String>) -> Self {
38        Self::Model(msg.into())
39    }
40
41    pub fn inference(msg: impl Into<String>) -> Self {
42        Self::Inference(msg.into())
43    }
44
45    pub fn tokenizer(msg: impl Into<String>) -> Self {
46        Self::Tokenizer(msg.into())
47    }
48
49    pub fn config(msg: impl Into<String>) -> Self {
50        Self::Config(msg.into())
51    }
52
53    pub fn runtime(msg: impl Into<String>) -> Self {
54        Self::Runtime(msg.into())
55    }
56}