Skip to main content

nucel_agent_core/
error.rs

1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, AgentError>;
4
5#[derive(Debug, Error)]
6pub enum AgentError {
7    #[error("provider error ({provider}): {message}")]
8    Provider { provider: String, message: String },
9
10    #[error("budget exceeded: spent ${spent:.2} of ${limit:.2}")]
11    BudgetExceeded { limit: f64, spent: f64 },
12
13    #[error("session not found: {session_id}")]
14    SessionNotFound { session_id: String },
15
16    #[error("agent CLI not found: {cli_name}")]
17    CliNotFound { cli_name: String },
18
19    #[error("configuration error: {0}")]
20    Config(String),
21
22    #[error("timeout after {seconds}s")]
23    Timeout { seconds: u64 },
24
25    #[error("agent requested escalation")]
26    EscalationRequested,
27
28    #[error(transparent)]
29    Io(#[from] std::io::Error),
30
31    #[error(transparent)]
32    Json(#[from] serde_json::Error),
33}