errors.py python
48 lines 1.2 KB
Raw
sha256:c07f2f34a0db9f43fe866f157d1935322008545ff8940c06c7c921eb219c55ab NXP-b DONE: independent BV-r2 pass + ISR (SD-17) Human minor ⚠ breaking 23 hours ago
1 """Typed errors for fail-closed adapter and config behavior."""
2
3 from __future__ import annotations
4
5 from dataclasses import dataclass
6
7
8 @dataclass(frozen=True)
9 class ReadError:
10 """Returned when a VCS read command fails; caller must halt."""
11
12 command: str
13 message: str = ""
14 exit_code: int | None = None
15
16 def __str__(self) -> str:
17 parts = [f"ReadError({self.command!r})"]
18 if self.message:
19 parts.append(self.message)
20 if self.exit_code is not None:
21 parts.append(f"exit={self.exit_code}")
22 return ": ".join(parts)
23
24
25 @dataclass(frozen=True)
26 class ConfigError(Exception):
27 """Raised when config is missing, unparseable, or unsupported."""
28
29 message: str
30 path: str | None = None
31 exit_code: int | None = None
32
33 def __str__(self) -> str:
34 if self.path:
35 return f"{self.path}: {self.message}"
36 return self.message
37
38
39 @dataclass(frozen=True)
40 class WriteError:
41 """Returned when a VCS write is refused or fails."""
42
43 command: str
44 message: str
45 exit_code: int | None = None
46
47 def __str__(self) -> str:
48 return f"WriteError({self.command!r}): {self.message}"
File History 1 commit
sha256:c07f2f34a0db9f43fe866f157d1935322008545ff8940c06c7c921eb219c55ab NXP-b DONE: independent BV-r2 pass + ISR (SD-17) Human minor 23 hours ago