Skip to content

Track 1: Add custom exception hierarchy #12

@nielsweistra

Description

@nielsweistra

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

  1. Create src/itl_policy_builder/exceptions.py with the hierarchy above
  2. Replace all raise ValueError(...) / raise RuntimeError(...) with the appropriate typed exception
  3. Export all exception classes from src/itl_policy_builder/__init__.py
  4. Add unit tests in tests/unit/test_exceptions.py

Acceptance Criteria

  • PolicyBuilderError is the base for all package-specific exceptions
  • All ValueError / RuntimeError in library code replaced with typed exceptions
  • Exception classes exported from package top-level
  • Unit tests covering each exception type
  • No breaking changes to existing public API signatures

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestrefactoringCode structure, architecture, and technical debt

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions