Skip to main content

thulp_skill_files/
error.rs

1//! Error types for skill file operations.
2
3use thiserror::Error;
4
5/// Result type alias for skill file operations.
6pub type Result<T> = std::result::Result<T, SkillFileError>;
7
8/// Errors that can occur when working with skill files.
9#[derive(Debug, Error)]
10pub enum SkillFileError {
11    /// IO error when reading/writing files.
12    #[error("IO error: {0}")]
13    Io(#[from] std::io::Error),
14
15    /// YAML parsing error in frontmatter.
16    #[error("YAML parsing error: {0}")]
17    Yaml(#[from] serde_yaml::Error),
18
19    /// General parsing error.
20    #[error("Parse error: {0}")]
21    Parse(String),
22
23    /// Invalid path provided.
24    #[error("Invalid path: {0}")]
25    InvalidPath(String),
26
27    /// Shell command execution error.
28    #[error("Command execution error: {0}")]
29    CommandExecution(String),
30
31    /// Variable not found during substitution.
32    #[error("Variable not found: {0}")]
33    VariableNotFound(String),
34
35    /// Skill not found in registry.
36    #[error("Skill not found: {0}")]
37    SkillNotFound(String),
38
39    /// Tool not allowed for skill execution.
40    #[error("Tool not allowed: {0}")]
41    ToolNotAllowed(String),
42
43    /// Skill requires user approval before execution.
44    #[error("Approval required for skill: {0}")]
45    ApprovalRequired(String),
46
47    /// Regex compilation error.
48    #[error("Regex error: {0}")]
49    Regex(#[from] regex::Error),
50}