Skip to main content

aether_project/
error.rs

1//! Error types for settings loading and validation.
2
3use aether_core::core::PromptSourceError;
4use thiserror::Error;
5
6/// Errors that can occur during settings loading and agent resolution.
7#[derive(Debug, Error)]
8pub enum SettingsError {
9    /// The settings file exists but could not be parsed.
10    #[error("Failed to parse settings file: {0}")]
11    ParseError(String),
12
13    /// An agent entry has an invalid model string.
14    #[error("Invalid model '{model}' for agent '{agent}': {error}")]
15    InvalidModel { agent: String, model: String, error: String },
16
17    /// An agent entry is missing required fields.
18    #[error("Agent '{agent}' is missing required field: {field}")]
19    MissingField { agent: String, field: String },
20
21    /// An agent entry has an empty name.
22    #[error("Agent at index {index} has an empty name")]
23    EmptyAgentName { index: usize },
24
25    /// An agent entry uses a reserved name.
26    #[error("Agent name '{name}' is reserved and cannot be used")]
27    ReservedAgentName { name: String },
28
29    /// Duplicate agent names.
30    #[error("Duplicate agent name: '{name}'")]
31    DuplicateAgentName { name: String },
32
33    /// An agent has no invocation surface enabled.
34    #[error("Agent '{agent}' must have at least one invocation flag (userInvocable or agentInvocable)")]
35    NoInvocationSurface { agent: String },
36
37    /// A prompt source on a specific agent failed validation.
38    #[error("Agent '{agent}': {source}")]
39    AgentPromptSource {
40        agent: String,
41        #[source]
42        source: PromptSourceError,
43    },
44
45    /// A prompt source failed validation outside an agent context.
46    #[error(transparent)]
47    PromptSource(#[from] PromptSourceError),
48
49    /// An agent has no prompts after inheritance.
50    #[error("Agent '{agent}' has no prompts after inheritance (neither inherited nor local)")]
51    NoPrompts { agent: String },
52
53    /// An MCP config path does not exist or is invalid.
54    #[error("MCP config path '{path}' does not exist or is not a file")]
55    InvalidMcpConfigPath { path: String },
56
57    /// I/O error while reading files.
58    #[error("I/O error: {0}")]
59    IoError(String),
60
61    /// An agent was not found in the catalog.
62    #[error("Agent '{name}' not found")]
63    AgentNotFound { name: String },
64
65    /// The authored config contains no agents.
66    #[error("Aether config must contain at least one agent")]
67    EmptyAgents,
68
69    /// The configured agent selector did not match an agent.
70    #[error("Configured agent selector '{name}' did not match any agent")]
71    InvalidAgentSelector { name: String },
72
73    /// The configured agent selector matched an agent that users cannot invoke.
74    #[error("Configured agent selector '{name}' is not user-invocable")]
75    NonUserInvocableAgentSelector { name: String },
76
77    /// Duplicate prompt names in the catalog.
78    #[error("Duplicate prompt name: '{name}'")]
79    DuplicatePromptName { name: String },
80}