Skip to main content

garudust_core/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum AgentError {
5    #[error("budget exhausted after {0} iterations")]
6    BudgetExhausted(u32),
7    #[error("token budget exhausted: {0} tokens used")]
8    TokenBudgetExhausted(u32),
9    #[error("transport error: {0}")]
10    Transport(#[from] TransportError),
11    #[error("tool error: {0}")]
12    Tool(#[from] ToolError),
13    #[error("context compression failed: {0}")]
14    Compression(String),
15    #[error("interrupted")]
16    Interrupted,
17    #[error(transparent)]
18    Other(#[from] anyhow::Error),
19}
20
21#[derive(Debug, Error)]
22pub enum TransportError {
23    #[error("HTTP error {status}: {body}")]
24    Http { status: u16, body: String },
25    #[error("rate limited, retry after {retry_after_secs}s")]
26    RateLimit { retry_after_secs: u64 },
27    #[error("network error: {0}")]
28    Network(String),
29    #[error("authentication failed")]
30    Auth,
31    #[error("model not found: {0}")]
32    ModelNotFound(String),
33    #[error("context length exceeded")]
34    ContextLengthExceeded,
35    #[error("stream error: {0}")]
36    Stream(String),
37    #[error("LLM call timed out after {0}s")]
38    Timeout(u64),
39    #[error(transparent)]
40    Other(#[from] anyhow::Error),
41}
42
43#[derive(Debug, Error)]
44pub enum ToolError {
45    #[error("tool not found: {0}")]
46    NotFound(String),
47    #[error("invalid arguments: {0}")]
48    InvalidArgs(String),
49    #[error("execution failed: {0}")]
50    Execution(String),
51    #[error("approval denied")]
52    ApprovalDenied,
53    #[error("tool '{0}' denied by active skill permissions")]
54    PermissionDenied(String),
55    #[error("tool timed out after {0}s")]
56    Timeout(u64),
57    #[error(transparent)]
58    Other(#[from] anyhow::Error),
59}
60
61#[derive(Debug, Error)]
62pub enum PlatformError {
63    #[error("connection error: {0}")]
64    Connection(String),
65    #[error("send failed: {0}")]
66    Send(String),
67    #[error("authentication failed")]
68    Auth,
69    #[error(transparent)]
70    Other(#[from] anyhow::Error),
71}