Skip to main content

aura_agent/core/
error.rs

1//! Agent Error Types
2//!
3//! Unified error handling for the agent runtime.
4
5use aura_core::AuraError;
6
7/// Agent-specific error types
8#[derive(Debug, thiserror::Error)]
9pub enum AgentError {
10    /// Configuration error
11    #[error("Agent configuration error: {0}")]
12    Config(String),
13
14    /// Runtime error
15    #[error("Agent runtime error: {0}")]
16    Runtime(String),
17
18    /// Authority context error
19    #[error("Authority context error: {0}")]
20    Context(String),
21
22    /// Effect system error
23    #[error("Effect system error: {0}")]
24    Effects(String),
25
26    /// Choreography error
27    #[error("Choreography error: {0}")]
28    Choreography(String),
29
30    /// Timeout error
31    #[error("Agent timeout error: {0}")]
32    Timeout(String),
33
34    /// Underlying Aura error
35    #[error("Aura error: {0}")]
36    Aura(#[from] AuraError),
37}
38
39/// Agent result type
40pub type AgentResult<T> = std::result::Result<T, AgentError>;
41
42impl AgentError {
43    /// Create a configuration error
44    pub fn config(msg: impl Into<String>) -> Self {
45        Self::Config(msg.into())
46    }
47
48    /// Create a runtime error
49    pub fn runtime(msg: impl Into<String>) -> Self {
50        Self::Runtime(msg.into())
51    }
52
53    /// Create a context error
54    pub fn context(msg: impl Into<String>) -> Self {
55        Self::Context(msg.into())
56    }
57
58    /// Create an effects error
59    pub fn effects(msg: impl Into<String>) -> Self {
60        Self::Effects(msg.into())
61    }
62
63    /// Create a choreography error
64    pub fn choreography(msg: impl Into<String>) -> Self {
65        Self::Choreography(msg.into())
66    }
67
68    /// Create a timeout error
69    pub fn timeout(msg: impl Into<String>) -> Self {
70        Self::Timeout(msg.into())
71    }
72
73    /// Create an internal error (alias for runtime error)
74    pub fn internal(msg: impl Into<String>) -> Self {
75        Self::Runtime(msg.into())
76    }
77
78    /// Create an invalid argument error (alias for config error)
79    pub fn invalid(msg: impl Into<String>) -> Self {
80        Self::Config(msg.into())
81    }
82}