Skip to main content

spn_mcp/
error.rs

1//! Error types for spn-mcp.
2
3use thiserror::Error;
4
5/// Result type alias for spn-mcp operations.
6pub type Result<T> = std::result::Result<T, Error>;
7
8/// Errors that can occur in spn-mcp.
9#[derive(Debug, Error)]
10pub enum Error {
11    /// Configuration file not found.
12    #[error("API configuration not found: {0}")]
13    ConfigNotFound(String),
14
15    /// Configuration parsing error.
16    #[error("Failed to parse configuration: {0}")]
17    ConfigParse(#[from] serde_yaml::Error),
18
19    /// Configuration validation error.
20    #[error("Invalid configuration: {0}")]
21    ConfigValidation(String),
22
23    /// Credential resolution error.
24    #[error("Failed to resolve credential '{0}': {1}")]
25    Credential(String, String),
26
27    /// HTTP request error.
28    #[error("HTTP request failed: {0}")]
29    Http(#[from] reqwest::Error),
30
31    /// Template rendering error.
32    #[error("Template rendering failed: {0}")]
33    Template(#[from] tera::Error),
34
35    /// JSON serialization error.
36    #[error("JSON error: {0}")]
37    Json(#[from] serde_json::Error),
38
39    /// IO error.
40    #[error("IO error: {0}")]
41    Io(#[from] std::io::Error),
42
43    /// MCP protocol error.
44    #[error("MCP error: {0}")]
45    Mcp(String),
46}