1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum ConfigError {
5 #[error("failed to load configuration: {0}")]
6 Load(Box<figment::Error>),
7
8 #[error("failed to serialize configuration: {0}")]
9 Serialize(#[from] toml::ser::Error),
10
11 #[error("failed to write configuration to {path}: {source}")]
12 Write {
13 path: std::path::PathBuf,
14 source: std::io::Error,
15 },
16
17 #[error("failed to read {path}: {source}")]
18 Read {
19 path: std::path::PathBuf,
20 source: std::io::Error,
21 },
22
23 #[error("failed to parse MCP configuration: {0}")]
24 McpParse(String),
25
26 #[error("failed to create configuration directory {path}: {source}")]
27 CreateDir {
28 path: std::path::PathBuf,
29 source: std::io::Error,
30 },
31
32 #[error("invalid language {language}: expected zh-CN or en-US")]
33 InvalidLanguage { language: String },
34
35 #[error("missing API key: set {env} or configure providers.*.api_key")]
36 MissingApiKey { env: String },
37
38 #[error("plugin hook failed: `{command}` (exit {code:?})")]
39 HookFailed { command: String, code: Option<i32> },
40}