Coverage for src / harnessutils / exceptions.py: 93%

15 statements  

« prev     ^ index     » next       coverage.py v7.13.2, created at 2026-02-18 08:30 -0600

1"""Custom exceptions for harness-utils with remediation guidance.""" 

2 

3 

4class HarnessError(Exception): 

5 """Base exception for harness-utils errors.""" 

6 

7 def __init__(self, message: str, remediation: str | None = None): 

8 """Initialize with error message and optional remediation steps. 

9 

10 Args: 

11 message: Error description 

12 remediation: Steps to fix the error 

13 """ 

14 self.message = message 

15 self.remediation = remediation 

16 super().__init__(self._format_error()) 

17 

18 def _format_error(self) -> str: 

19 """Format error with remediation if available.""" 

20 if self.remediation: 

21 return f"{self.message}\n\nHow to fix:\n{self.remediation}" 

22 return self.message 

23 

24 

25class ConfigurationError(HarnessError): 

26 """Invalid configuration detected.""" 

27 

28 

29class PruningError(HarnessError): 

30 """Error during pruning operation.""" 

31 

32 

33class SummarizationError(HarnessError): 

34 """Error during summarization operation.""" 

35 

36 

37class TruncationError(HarnessError): 

38 """Error during truncation operation.""" 

39 

40 

41class SnapshotError(HarnessError): 

42 """Error with snapshot operations.""" 

43 

44 

45class StorageError(HarnessError): 

46 """Error with storage backend."""