spec_kit_mcp/speckit/
errors.rs

1//! Spec-Kit Error Types
2
3use thiserror::Error;
4
5/// Errors that can occur when interacting with spec-kit CLI
6#[derive(Error, Debug)]
7pub enum SpecKitError {
8    #[error("Spec-kit CLI not found. Please install with: uv tool install specify-cli")]
9    CliNotFound,
10
11    #[error("Python 3.11+ required but not found")]
12    PythonVersionTooOld,
13
14    #[error("Spec-kit command failed: {command}\nStderr: {stderr}\nExit code: {exit_code}")]
15    CommandFailed {
16        command: String,
17        stderr: String,
18        exit_code: i32,
19    },
20
21    #[error("Failed to parse spec-kit output: {0}")]
22    ParseError(String),
23
24    #[error("Timeout waiting for spec-kit command")]
25    Timeout,
26
27    #[error("Invalid path: {0}")]
28    InvalidPath(String),
29
30    #[error("File operation failed: {0}")]
31    FileError(String),
32
33    #[error("IO error: {0}")]
34    IoError(#[from] std::io::Error),
35}
36
37impl SpecKitError {
38    /// Create a command failed error
39    pub fn command_failed(
40        command: impl Into<String>,
41        stderr: impl Into<String>,
42        exit_code: i32,
43    ) -> Self {
44        Self::CommandFailed {
45            command: command.into(),
46            stderr: stderr.into(),
47            exit_code,
48        }
49    }
50}