errors.py python
48 lines 1.2 KB
Raw
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 1 day 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 2 commits
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 1 day ago
sha256:4671b7f787ddbe63ced31c895b688c77ab495653b65a730b423329f26b3c1439 feat: K1-P1 complete — agent provenance, build-verification… Sonnet 4.6 patch 53 days ago