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 selects a reasoning effort unsupported by its model.
18    #[error("Agent '{agent}' has invalid reasoning effort: {source}")]
19    InvalidReasoningEffort {
20        agent: String,
21        #[source]
22        source: llm::catalog::ReasoningEffortError,
23    },
24
25    /// An agent entry is missing required fields.
26    #[error("Agent '{agent}' is missing required field: {field}")]
27    MissingField { agent: String, field: String },
28
29    /// An agent entry has an invalid context window.
30    #[error("Agent '{agent}' has invalid contextWindow {context_window}; expected a positive integer")]
31    InvalidContextWindow { agent: String, context_window: u32 },
32
33    /// An agent entry has an empty name.
34    #[error("Agent at index {index} has an empty name")]
35    EmptyAgentName { index: usize },
36
37    /// An agent entry uses a reserved name.
38    #[error("Agent name '{name}' is reserved and cannot be used")]
39    ReservedAgentName { name: String },
40
41    /// Duplicate agent names.
42    #[error("Duplicate agent name: '{name}'")]
43    DuplicateAgentName { name: String },
44
45    /// An agent has no invocation surface enabled.
46    #[error("Agent '{agent}' must have at least one invocation flag (userInvocable or agentInvocable)")]
47    NoInvocationSurface { agent: String },
48
49    /// A prompt source on a specific agent failed validation.
50    #[error("Agent '{agent}': {source}")]
51    AgentPromptSource {
52        agent: String,
53        #[source]
54        source: PromptSourceError,
55    },
56
57    /// A prompt source failed validation outside an agent context.
58    #[error(transparent)]
59    PromptSource(#[from] PromptSourceError),
60
61    /// An agent has no prompts declared (neither inherited nor local).
62    #[error("Agent '{agent}' has no prompts declared (neither inherited nor local)")]
63    NoPromptsDeclared { agent: String },
64
65    /// An agent declared prompts but every entry was optional and matched no files.
66    #[error("Agent '{agent}': all prompt entries were optional and matched no files")]
67    AllOptionalPromptsMissing { agent: String },
68
69    /// An MCP config path does not exist or is invalid.
70    #[error("MCP config path '{path}' does not exist or is not a file")]
71    InvalidMcpConfigPath { path: String },
72
73    /// A `${VAR}` reference in an MCP config path could not be resolved.
74    #[error("MCP config path '{path}' references undefined variable '{variable}'")]
75    UnresolvedMcpConfigVariable { path: String, variable: String },
76
77    /// I/O error while reading files.
78    #[error("I/O error: {0}")]
79    IoError(String),
80
81    /// An agent was not found in the catalog.
82    #[error("Agent '{name}' not found")]
83    AgentNotFound { name: String },
84
85    /// The authored config contains no agents.
86    #[error("Aether config must contain at least one agent")]
87    EmptyAgents,
88
89    /// The authored config contains no user-invocable agents.
90    #[error("Aether config must contain at least one user-invocable agent")]
91    NoUserInvocableAgents,
92
93    /// The configured agent selector did not match an agent.
94    #[error("Configured agent selector '{name}' did not match any agent")]
95    InvalidAgentSelector { name: String },
96
97    /// The configured agent selector matched an agent that users cannot invoke.
98    #[error("Configured agent selector '{name}' is not user-invocable")]
99    NonUserInvocableAgentSelector { name: String },
100
101    /// Duplicate prompt names in the catalog.
102    #[error("Duplicate prompt name: '{name}'")]
103    DuplicatePromptName { name: String },
104}