Coverage for sygaldry / errors.py: 95%
34 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-06 19:06 -0400
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-06 19:06 -0400
1from __future__ import annotations
3__author__ = "Rohan B. Dalton"
5from typing import Optional
8class SygaldryError(Exception):
9 """
10 Base error for all Sygaldry failures.
12 :param message: Human-readable error message.
13 :param file_path: Source config file path, if known.
14 :param config_path: Dotted config path for context.
15 :type message: str
16 :type file_path: str | None
17 :type config_path: str | None
18 """
20 def __init__(
21 self,
22 message: str,
23 file_path: str | None = None,
24 config_path: str | None = None,
25 ):
26 super().__init__(message)
27 self._message = message
28 self._file_path = file_path
29 self._config_path = config_path
31 def __str__(self) -> str:
32 """
33 Render the error with optional file/config context.
35 :returns: Formatted error string with file and config path context.
36 :rtype: str
37 """
38 parts = list()
39 if self._file_path:
40 parts.append(f"file='{self._file_path}'")
41 if self._config_path:
42 parts.append(f"path='{self._config_path}'")
43 if parts:
44 return f"{self._message} ({', '.join(parts)})"
45 return self._message
48class LoadError(SygaldryError):
49 """
50 Errors during file loading or parsing.
51 """
54class ParseError(LoadError):
55 """
56 Parsing failures for YAML or TOML.
57 """
60class IncludeError(LoadError):
61 """
62 Errors during include resolution or deep merge.
63 """
66class CircularIncludeError(IncludeError):
67 """
68 Circular include detected.
69 """
72class ValidationError(SygaldryError):
73 """
74 Schema or config validation failures.
75 """
78class ConfigReferenceError(ValidationError):
79 """
80 Missing or invalid _ref targets.
81 """
84class CircularReferenceError(ConfigReferenceError):
85 """
86 Circular _ref detected.
87 """
90class InterpolationError(ValidationError):
91 """
92 Interpolation failures.
93 """
96class CircularInterpolationError(InterpolationError):
97 """
98 Circular interpolation detected.
99 """
102class ImportResolutionError(SygaldryError):
103 """
104 Import or dotted path resolution failures.
105 """
108class ResolutionError(SygaldryError):
109 """
110 Errors during recursive resolution.
111 """
114class ConstructorError(ResolutionError):
115 """
116 Constructor invocation failures.
117 """
120class ConfigConflictError(SygaldryError):
121 """
122 Cache conflicts for identical keys with differing specs.
123 """
126class CLIError(SygaldryError):
127 """
128 Errors originating from CLI argument processing.
129 """
132if __name__ == "__main__": 132 ↛ 133line 132 didn't jump to line 133 because the condition on line 132 was never true
133 pass