nucel_agent_core/
error.rs1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, AgentError>;
4
5#[derive(Debug, Error)]
6#[non_exhaustive]
7pub enum AgentError {
8 #[error("provider error ({provider}): {message}")]
9 Provider { provider: String, message: String },
10
11 #[error("budget exceeded: spent ${spent:.2} of ${limit:.2}")]
12 BudgetExceeded { limit: f64, spent: f64 },
13
14 #[error("session not found: {session_id}")]
15 SessionNotFound { session_id: String },
16
17 #[error("agent CLI not found: {cli_name}")]
18 CliNotFound { cli_name: String },
19
20 #[error("configuration error: {0}")]
21 Config(String),
22
23 #[error("timeout after {seconds}s")]
24 Timeout { seconds: u64 },
25
26 #[error("agent requested escalation")]
27 EscalationRequested,
28
29 #[error("stream interrupted: {0}")]
31 StreamInterrupted(String),
32
33 #[error("rate limited: {message}")]
35 RateLimited { message: String },
36
37 #[error("hook '{hook}' failed: {message}")]
39 HookFailed { hook: String, message: String },
40
41 #[error(transparent)]
42 Io(#[from] std::io::Error),
43
44 #[error(transparent)]
45 Json(#[from] serde_json::Error),
46}