Track 1: Add custom exception hierarchy
Overview
All error paths in itl-policy-builder currently raise bare ValueError or
RuntimeError. This makes it impossible for callers to catch errors at the right
level of specificity without catching all Exceptions.
Goal
Introduce a typed exception hierarchy rooted at PolicyBuilderError:
class PolicyBuilderError(Exception): ...
class PolicyValidationError(PolicyBuilderError): ...
class PolicyEvaluationError(PolicyBuilderError): ...
class PolicyDeployError(PolicyBuilderError): ...
class PolicyExportError(PolicyBuilderError): ...
Implementation Steps
- Create
src/itl_policy_builder/exceptions.py with the hierarchy above
- Replace all
raise ValueError(...) / raise RuntimeError(...) with the appropriate typed exception
- Export all exception classes from
src/itl_policy_builder/__init__.py
- Add unit tests in
tests/unit/test_exceptions.py
Acceptance Criteria
Track 1: Add custom exception hierarchy
Overview
All error paths in
itl-policy-buildercurrently raise bareValueErrororRuntimeError. This makes it impossible for callers to catch errors at the rightlevel of specificity without catching all
Exceptions.Goal
Introduce a typed exception hierarchy rooted at
PolicyBuilderError:Implementation Steps
src/itl_policy_builder/exceptions.pywith the hierarchy aboveraise ValueError(...)/raise RuntimeError(...)with the appropriate typed exceptionsrc/itl_policy_builder/__init__.pytests/unit/test_exceptions.pyAcceptance Criteria
PolicyBuilderErroris the base for all package-specific exceptionsValueError/RuntimeErrorin library code replaced with typed exceptions