Skip to main content

aura_agent/builder/
error.rs

1//! Build error types for the runtime builder system.
2
3use std::fmt;
4
5/// Error type for runtime builder operations
6#[derive(Debug)]
7pub enum BuildError {
8    /// Runtime construction requires explicit bootstrap identity first
9    BootstrapRequired {
10        /// Preset/runtime surface requiring bootstrap
11        preset: &'static str,
12        /// Missing identity field
13        identity: &'static str,
14    },
15
16    /// A required configuration value is missing
17    MissingRequired(&'static str),
18
19    /// Invalid configuration value
20    InvalidConfig {
21        field: &'static str,
22        message: String,
23    },
24
25    /// Effect initialization failed
26    EffectInit {
27        effect: &'static str,
28        message: String,
29    },
30
31    /// Runtime construction failed
32    RuntimeConstruction(String),
33
34    /// Authority context error
35    AuthorityError(String),
36}
37
38impl fmt::Display for BuildError {
39    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
40        match self {
41            Self::BootstrapRequired { preset, identity } => {
42                write!(
43                    f,
44                    "{preset} bootstrap required: missing explicit {identity}; create or load an account identity first"
45                )
46            }
47            Self::MissingRequired(field) => {
48                write!(f, "missing required configuration: {}", field)
49            }
50            Self::InvalidConfig { field, message } => {
51                write!(f, "invalid configuration for '{}': {}", field, message)
52            }
53            Self::EffectInit { effect, message } => {
54                write!(f, "failed to initialize {} effect: {}", effect, message)
55            }
56            Self::RuntimeConstruction(msg) => {
57                write!(f, "runtime construction failed: {}", msg)
58            }
59            Self::AuthorityError(msg) => {
60                write!(f, "authority error: {}", msg)
61            }
62        }
63    }
64}
65
66impl std::error::Error for BuildError {}
67
68impl From<BuildError> for crate::AgentError {
69    fn from(e: BuildError) -> Self {
70        crate::AgentError::config(e.to_string())
71    }
72}