File size: 1,218 Bytes
c62d538
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! Spec-Kit Error Types

use thiserror::Error;

/// Errors that can occur when interacting with spec-kit CLI
#[derive(Error, Debug)]
pub enum SpecKitError {
    #[error("Spec-kit CLI not found. Please install with: uv tool install specify-cli")]
    CliNotFound,

    #[error("Python 3.11+ required but not found")]
    PythonVersionTooOld,

    #[error("Spec-kit command failed: {command}\nStderr: {stderr}\nExit code: {exit_code}")]
    CommandFailed {
        command: String,
        stderr: String,
        exit_code: i32,
    },

    #[error("Failed to parse spec-kit output: {0}")]
    ParseError(String),

    #[error("Timeout waiting for spec-kit command")]
    Timeout,

    #[error("Invalid path: {0}")]
    InvalidPath(String),

    #[error("File operation failed: {0}")]
    FileError(String),

    #[error("IO error: {0}")]
    IoError(#[from] std::io::Error),
}

impl SpecKitError {
    /// Create a command failed error
    pub fn command_failed(
        command: impl Into<String>,
        stderr: impl Into<String>,
        exit_code: i32,
    ) -> Self {
        Self::CommandFailed {
            command: command.into(),
            stderr: stderr.into(),
            exit_code,
        }
    }
}