Skip to main content

ferro_api_mcp/
error.rs

1/// Errors that can occur in the ferro-api-mcp server.
2#[derive(Debug, thiserror::Error)]
3pub enum Error {
4    /// Failed to fetch the OpenAPI spec from the given URL.
5    #[error("failed to fetch OpenAPI spec: {0}")]
6    SpecFetch(String),
7
8    /// Failed to parse the OpenAPI spec JSON.
9    #[error("failed to parse OpenAPI spec: {0}")]
10    SpecParse(String),
11
12    /// The OpenAPI spec version is not supported (only 3.0.x).
13    #[error("unsupported OpenAPI version: {0}")]
14    UnsupportedVersion(String),
15
16    /// A `$ref` in the spec could not be resolved.
17    #[error("unresolved $ref: {0}")]
18    UnresolvedRef(String),
19
20    /// HTTP client error during an API call.
21    #[error("HTTP client error: {0}")]
22    HttpClient(String),
23
24    /// The API returned a non-success status code.
25    #[error("API error (status {status}): {body}")]
26    ApiError { status: u16, body: String },
27
28    /// Error during MCP tool execution.
29    #[error("tool execution error: {0}")]
30    ToolExecution(String),
31
32    /// MCP server error.
33    #[error("server error: {0}")]
34    Server(String),
35}