Coverage for src / agent / skills / errors.py: 100%

10 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2025-12-11 14:30 +0000

1# Copyright 2025-2026 Microsoft Corporation 

2# 

3# Licensed under the Apache License, Version 2.0 (the "License"); 

4# you may not use this file except in compliance with the License. 

5# You may obtain a copy of the License at 

6# 

7# http://www.apache.org/licenses/LICENSE-2.0 

8# 

9# Unless required by applicable law or agreed to in writing, software 

10# distributed under the License is distributed on an "AS IS" BASIS, 

11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

12# See the License for the specific language governing permissions and 

13# limitations under the License. 

14 

15"""Custom exceptions for skill subsystem. 

16 

17This module defines a hierarchy of domain-specific exceptions for the 

18skill plugin system. 

19 

20Exception Hierarchy: 

21 SkillError (base) 

22 ├── SkillNotFoundError 

23 ├── SkillManifestError 

24 ├── SkillDependencyError 

25 └── SkillSecurityError 

26""" 

27 

28 

29class SkillError(Exception): 

30 """Base exception for all skill-related errors. 

31 

32 All custom exceptions in the skill subsystem inherit from this base class, 

33 allowing for catch-all error handling when needed. 

34 

35 Example: 

36 >>> try: 

37 ... # some skill operation 

38 ... pass 

39 ... except SkillError as e: 

40 ... print(f"Skill error: {e}") 

41 """ 

42 

43 pass 

44 

45 

46class SkillNotFoundError(SkillError): 

47 """Skill not found in registry or filesystem. 

48 

49 Raised when attempting to load or use a skill that doesn't exist 

50 or isn't installed. 

51 

52 Example: 

53 >>> raise SkillNotFoundError("Skill 'kalshi-markets' not found") 

54 """ 

55 

56 pass 

57 

58 

59class SkillManifestError(SkillError): 

60 """Skill manifest (SKILL.md) validation or parsing errors. 

61 

62 Raised when SKILL.md is missing, malformed, or contains invalid 

63 YAML front matter or required fields. 

64 

65 Example: 

66 >>> raise SkillManifestError("Missing required field 'name' in SKILL.md") 

67 """ 

68 

69 pass 

70 

71 

72class SkillDependencyError(SkillError): 

73 """Skill dependency validation errors. 

74 

75 Raised when a skill's Python dependencies are missing or incompatible, 

76 or when min/max version requirements aren't met. 

77 

78 Example: 

79 >>> raise SkillDependencyError("Skill requires osdu-agent>=0.2.0, found 0.1.0") 

80 """ 

81 

82 pass 

83 

84 

85class SkillSecurityError(SkillError): 

86 """Skill security validation errors. 

87 

88 Raised when skill name sanitization fails, path traversal is detected, 

89 or trust validation fails. 

90 

91 Example: 

92 >>> raise SkillSecurityError("Invalid skill name: '../etc/passwd'") 

93 """ 

94 

95 pass