omega_runtime/
error.rs

1//! Error types for the Omega Runtime
2
3use thiserror::Error;
4
5/// Errors that can occur during runtime operations
6#[derive(Debug, Error)]
7pub enum RuntimeError {
8    #[error("Configuration error: {0}")]
9    Config(String),
10
11    #[error("Initialization error: {0}")]
12    Initialization(String),
13
14    #[error("Shutdown error: {0}")]
15    Shutdown(String),
16
17    #[error("State transition error: current={current}, attempted={attempted}")]
18    InvalidStateTransition { current: String, attempted: String },
19
20    #[error("Component error - {component}: {error}")]
21    Component { component: String, error: String },
22
23    #[error("AgentDB error: {0}")]
24    AgentDB(String),
25
26    #[error("Memory error: {0}")]
27    Memory(String),
28
29    #[error("Loop engine error: {0}")]
30    LoopEngine(String),
31
32    #[error("Meta-SONA error: {0}")]
33    MetaSONA(String),
34
35    #[error("Event bus error: {0}")]
36    EventBus(String),
37
38    #[error("API error: {0}")]
39    API(String),
40
41    #[error("IO error: {0}")]
42    Io(#[from] std::io::Error),
43
44    #[error("Serialization error: {0}")]
45    Serialization(#[from] serde_json::Error),
46
47    #[error("Runtime is not initialized")]
48    NotInitialized,
49
50    #[error("Runtime is already running")]
51    AlreadyRunning,
52
53    #[error("Runtime is not running")]
54    NotRunning,
55
56    #[error("Operation timeout")]
57    Timeout,
58
59    #[error("Unknown error: {0}")]
60    Unknown(String),
61}
62
63/// Errors that can occur during configuration
64#[derive(Debug, Error)]
65pub enum ConfigError {
66    #[error("Invalid configuration: {0}")]
67    Invalid(String),
68
69    #[error("Missing required field: {0}")]
70    MissingField(String),
71
72    #[error("File not found: {0}")]
73    FileNotFound(String),
74
75    #[error("Parse error: {0}")]
76    Parse(String),
77
78    #[error("IO error: {0}")]
79    Io(#[from] std::io::Error),
80
81    #[error("Serialization error: {0}")]
82    Serialization(#[from] serde_json::Error),
83
84    #[error("Validation error: {0}")]
85    Validation(String),
86}
87
88/// Errors that can occur during API operations
89#[derive(Debug, Error)]
90pub enum APIError {
91    #[error("Runtime error: {0}")]
92    Runtime(#[from] RuntimeError),
93
94    #[error("Invalid request: {0}")]
95    InvalidRequest(String),
96
97    #[error("Resource not found: {0}")]
98    NotFound(String),
99
100    #[error("Operation not supported: {0}")]
101    NotSupported(String),
102
103    #[error("Internal error: {0}")]
104    Internal(String),
105}
106
107/// Result type for runtime operations
108pub type RuntimeResult<T> = Result<T, RuntimeError>;
109
110/// Result type for configuration operations
111pub type ConfigResult<T> = Result<T, ConfigError>;
112
113/// Result type for API operations
114pub type APIResult<T> = Result<T, APIError>;