Skip to main content

mcpkit_rs_config/
error.rs

1//! Error types for the configuration system
2
3use thiserror::Error;
4
5/// Result type alias
6pub type Result<T> = std::result::Result<T, ConfigError>;
7
8/// Configuration error type
9#[derive(Error, Debug)]
10pub enum ConfigError {
11    #[error("Configuration parsing error: {0}")]
12    ParseError(String),
13
14    #[error("Configuration validation error: {0}")]
15    ValidationError(String),
16
17    #[error("IO error: {0}")]
18    IoError(#[from] std::io::Error),
19
20    #[error("YAML error: {0}")]
21    YamlError(#[from] serde_yaml::Error),
22
23    #[error("JSON error: {0}")]
24    JsonError(#[from] serde_json::Error),
25
26    #[error("Version mismatch: expected {expected}, found {found}")]
27    VersionMismatch { expected: String, found: String },
28
29    #[error("Invalid runtime type: {0}")]
30    InvalidRuntimeType(String),
31
32    #[error("Invalid transport type: {0}")]
33    InvalidTransportType(String),
34
35    #[error("Missing required field: {0}")]
36    MissingField(String),
37
38    #[error("Invalid value for {field}: {value}")]
39    InvalidValue { field: String, value: String },
40
41    #[error("Policy error: {0}")]
42    PolicyError(#[from] mcpkit_rs_policy::PolicyError),
43
44    #[error("Configuration not found at path: {0}")]
45    NotFound(String),
46
47    #[error("Merge conflict: {0}")]
48    MergeConflict(String),
49
50    #[error("Other error: {0}")]
51    Other(#[from] anyhow::Error),
52}