Coverage for src/indium/_exceptions.py: 100%
9 statements
« prev ^ index » next coverage.py v7.10.7, created at 2026-01-08 22:34 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2026-01-08 22:34 +0000
1"""Exception hierarchy for indium.
3Following elemental-* family pattern: all exceptions inherit from ValueError
4for compatibility with standard validation flows.
5"""
7from typing import Optional
10class IndiumError(ValueError):
11 """Base exception for all indium errors."""
13 pass
16class InvalidTextError(IndiumError):
17 """Raised when text contains invalid or malformed Unicode.
19 Attributes:
20 position: Optional position where the invalid character was found
21 """
23 def __init__(self, message: str, position: Optional[int] = None) -> None:
24 """Initialize InvalidTextError.
26 Args:
27 message: Error description
28 position: Position of invalid character (if known)
29 """
30 super().__init__(message)
31 self.position = position
34class TruncationError(IndiumError):
35 """Raised when text cannot be safely truncated at requested position.
37 This may occur when the truncation point falls within a grapheme cluster
38 that cannot be split.
39 """
41 pass