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 invalid context window.
22    #[error("Agent '{agent}' has invalid contextWindow {context_window}; expected a positive integer")]
23    InvalidContextWindow { agent: String, context_window: u32 },
24
25    /// An agent entry has an empty name.
26    #[error("Agent at index {index} has an empty name")]
27    EmptyAgentName { index: usize },
28
29    /// An agent entry uses a reserved name.
30    #[error("Agent name '{name}' is reserved and cannot be used")]
31    ReservedAgentName { name: String },
32
33    /// Duplicate agent names.
34    #[error("Duplicate agent name: '{name}'")]
35    DuplicateAgentName { name: String },
36
37    /// An agent has no invocation surface enabled.
38    #[error("Agent '{agent}' must have at least one invocation flag (userInvocable or agentInvocable)")]
39    NoInvocationSurface { agent: String },
40
41    /// A prompt source on a specific agent failed validation.
42    #[error("Agent '{agent}': {source}")]
43    AgentPromptSource {
44        agent: String,
45        #[source]
46        source: PromptSourceError,
47    },
48
49    /// A prompt source failed validation outside an agent context.
50    #[error(transparent)]
51    PromptSource(#[from] PromptSourceError),
52
53    /// An agent has no prompts after inheritance.
54    #[error("Agent '{agent}' has no prompts after inheritance (neither inherited nor local)")]
55    NoPrompts { agent: String },
56
57    /// An MCP config path does not exist or is invalid.
58    #[error("MCP config path '{path}' does not exist or is not a file")]
59    InvalidMcpConfigPath { path: String },
60
61    /// I/O error while reading files.
62    #[error("I/O error: {0}")]
63    IoError(String),
64
65    /// An agent was not found in the catalog.
66    #[error("Agent '{name}' not found")]
67    AgentNotFound { name: String },
68
69    /// The authored config contains no agents.
70    #[error("Aether config must contain at least one agent")]
71    EmptyAgents,
72
73    /// The configured agent selector did not match an agent.
74    #[error("Configured agent selector '{name}' did not match any agent")]
75    InvalidAgentSelector { name: String },
76
77    /// The configured agent selector matched an agent that users cannot invoke.
78    #[error("Configured agent selector '{name}' is not user-invocable")]
79    NonUserInvocableAgentSelector { name: String },
80
81    /// Duplicate prompt names in the catalog.
82    #[error("Duplicate prompt name: '{name}'")]
83    DuplicatePromptName { name: String },
84}