Skip to content

Introduce Error and Exception base abstractions#8

Merged
dieselxxx merged 10 commits into
developfrom
architecture/error-exception-base
Jun 25, 2026
Merged

Introduce Error and Exception base abstractions#8
dieselxxx merged 10 commits into
developfrom
architecture/error-exception-base

Conversation

@dieselxxx

@dieselxxx dieselxxx commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

🧱 System Design / Architecture Pull Request

Related Issue

Description

  • What architectural decision is being implemented?

    • This PR introduces a unified FireHub-native error and exception abstraction layer inside FireHub\Core\Error, defining two base classes: Error and Exception as the foundational contract for all framework-level failures.
  • What system boundary or rule is being defined?

    • It establishes a strict architectural rule that all FireHub Core components MUST use FireHub-defined error abstractions instead of directly using PHP native \Error, \Exception, or generic \Throwable types.
    • It also defines a clear separation between system-level failures (Error) and runtime/domain-level failures (Exception).
  • Why is this architecture required?

    • To decouple FireHub Core from PHP internal throwable hierarchy and create a consistent, framework-owned error model.
    • To ensure predictable error semantics across all layers of the ecosystem.
    • To enable future extensibility into structured error classification (Domain, Runtime, System, Validation).
    • To improve testability and enforceable architectural contracts across Core and dependent packages.
  • What parts of Core / Runtime / Adapter / Capability are affected?

    • Core: Introduces the foundational error abstraction layer used by all core components.
    • Runtime: Will adopt this model for execution-time failures and runtime boundary handling.
    • Adapter: Will map external system/transport errors (HTTP, CLI, etc.) into FireHub error types.
    • Capability: Will use structured exceptions for feature-level failure handling and extension logic.

Architecture Overview

System Design

Introduces a foundational exception hierarchy for the FireHub Core layer. The architecture establishes a common base abstraction for all framework-defined exceptions and provides semantic categories for domain, runtime, and security concerns.

Design Decisions

Key architectural decisions made

  • Introduce FireHubException as the single root exception abstraction.

  • Categorize exceptions by responsibility:

    • Domain
    • Runtime
    • Security
  • Allow specialized exceptions to extend semantic categories.

  • Integrate future support for strongly typed error codes through the Code Value Object.

Why these decisions were chosen

  • Establishes a consistent exception model across the FireHub ecosystem.
  • Provides clear separation of failure categories.
  • Enables future Runtime, Adapter, and Capability packages to build upon stable exception contracts.
  • Avoids direct dependency on framework-external exception hierarchies.

Rejected alternatives

  • Introducing a parallel FireHubError hierarchy.
  • Using only PHP native exceptions without framework abstractions.
  • Creating highly granular exception types at the Core level.
  • Introducing exception factories or infrastructure-specific exceptions within Core.

System Boundaries

Included

  • Exception contracts and hierarchy definitions.
  • Framework-level exception categorization.
  • Value Object validation exception support.
  • Future extension points for error codes and exception metadata.

Excluded

  • Runtime logic.
  • Infrastructure concerns.
  • Adapters and external integrations.
  • HTTP-specific exceptions.
  • Persistence-specific exceptions.
  • Logging and monitoring concerns.
  • Exception handling policies.

Implementation

Core Changes

Files / modules introduced or modified

  • FireHub\Core\Exception\FireHubException
  • FireHub\Core\Exception\DomainException
  • FireHub\Core\Exception\RuntimeException
  • FireHub\Core\Exception\SecurityException
  • FireHub\Core\Exception\Domain\ValidationException
  • FireHub\Core\Exception\Runtime\SystemException
  • FireHub\Core\Exception\Runtime\InvariantException
  • FireHub\Core\Exception\Code

Contracts

ValueObjects

  • Code

Exceptions

  • FireHubException
  • DomainException
  • RuntimeException
  • SecurityException
  • ValidationException
  • SystemException
  • InvariantException

Interfaces

  • None

Dependencies

New dependencies introduced

  • None

Impact on existing packages

  • core-standard: Introduces foundational exception contracts.
  • core-professional: May extend the hierarchy with advanced exception types.
  • core-enterprise: May build enterprise-specific exception strategies on top of these contracts.

Validation

Architecture Compliance

  • Matches defined Architecture issue
  • No violation of Core / Runtime separation
  • No unintended business logic introduced
  • No infrastructure logic inside Core

Build & Stability

  • Project builds successfully
  • No breaking changes (or properly documented)
  • Backward compatibility considered

Impact Analysis

Core Impact

Introduces the first standardized exception model for the FireHub ecosystem and establishes a stable contract for future framework extensions.

Runtime Impact

None immediately required. Runtime implementations may gradually migrate to the new exception hierarchy.

Future Extensions

  • Standardized exception handling across all FireHub packages.
  • Strongly typed error code support.
  • Consistent error propagation mechanisms.
  • Framework-wide exception categorization.
  • Future adapter-level exception mapping.

Risks / Constraints

Risk Level

  • None
  • Low
  • Medium
  • High

Potential Risks

Architecture lock-in

Low. The hierarchy remains intentionally small and extensible.

Breaking changes for downstream packages

Minimal. Existing implementations may continue using native PHP exceptions until migration is desired.

Over-abstraction risks

Mitigated by limiting the number of exception categories introduced in Core.

Documentation

  • Architecture documented in repository / docs
  • Design decisions explained
  • Examples provided (if applicable)
  • Migration notes are added (if needed)

Checklist

  • Architecture issue linked
  • System boundaries are clearly defined
  • Core/Runtime separation respected
  • No experimental or temporary code included
  • Implementation matches architectural design
  • Reviewed for long-term maintainability

Notes

Technical Notes

This architecture intentionally relies on PHP's native Error hierarchy and introduces only framework-specific exception abstractions. Core remains responsible for contracts and categorization, while Runtime remains responsible for exception handling behavior.

Future Work

  • Introduce framework-wide error code catalog.
  • Add additional domain-specific exception types.
  • Add adapter-level exception mapping strategies.
  • Introduce structured exception metadata support.
  • Introduce serialization contracts for exceptions.

Reviewer Guidance

  • Focus on:
    • Architectural correctness.
    • Boundary enforcement.
    • Exception hierarchy design.
    • Future extensibility.
    • Long-term maintainability.

**Details:**
- Updated badge links and branch references to point to the `architecture/error-exception-base` branch.
- Adjusted branch purpose and overview to describe the introduction of a **core error and exception abstraction layer**.
- Added detailed sections explaining architectural goals, core concepts, and the FireHub-native error system.
- Introduced related milestone, pull request, and repository metadata to enhance clarity on progress and objectives.
- This update formalizes the foundation for structured error handling in the FireHub ecosystem and prepares it for future architectural expansions.
@dieselxxx dieselxxx added the type: Architecture Represent changes that define, enforce, or modify the structural design of the FireHub ecosystem. label Jun 24, 2026
@dieselxxx dieselxxx linked an issue Jun 24, 2026 that may be closed by this pull request
2 tasks
@dieselxxx dieselxxx moved this from Todo to Done in 🚩 Triage Jun 24, 2026
@dieselxxx dieselxxx moved this from Backlog to Draft in 📌 Core Development: v0 → v1 Jun 24, 2026
**Details:**
- Added a `FireHubException` base class along with specialized subtypes (`DomainException`, `RuntimeException`, `ValidationException`, etc.) to establish a structured exception hierarchy for the FireHub ecosystem.
- Introduced `Code` value object as a type-safe representation of error codes with invariant enforcement.
- Implemented concrete exceptions such as `InvalidCodeValueException` to handle specific invariant violations.
- Refactored `ValueObject` to incorporate stricter exception handling and validation mechanisms.
- Updated existing `ValueObject` tests to use the new exception types and replaced generic exceptions with FireHub-native ones.
- Added unit tests for:
  - `DomainException`, `RuntimeException`, `SecurityException`, and other exception subtypes.
  - `Code` value object validation and functionality.
  - Dummy exception stubs for base test scenarios.
- Enhanced test coverage and enforced consistent exception handling, laying a foundation for robust error management in the framework.
**Details:**
- Introduced a GitHub Actions workflow (`Codecov.yml`) to automate code coverage reporting on pull requests targeting `master`, `develop`, and versioned branches (`v*`).
- Integrated reusable workflow from the central repository to streamline maintenance and enforce consistency.
- Added `codecov.yaml` to configure coverage thresholds:
  - Set a project-wide target of 70%.
  - Defined higher coverage targets (80%) for `Exception` and `Type` modules to promote critical code robustness.
- Utilized GitHub and Codecov tokens for secure authentication.

This enhances the repository with automated coverage tracking, enforces quality targets, and ensures visibility into test reliability across critical components.
**Details:**
- Enhanced `phpunit.xml` by adding `integration` and `smoke` test suites, expanding the testing scope beyond unit tests.
- Updated the Codecov workflow (`Codecov.yml`) to monitor release branches with the pattern `release/v*` instead of `v*`, ensuring consistency with branching conventions.
- These changes improve test organization and maintain alignment with the repository's versioning strategy.
**Details:**
- Added `.gitkeep` files to `Core-Standard/tests/Smoke` and `Core-Standard/tests/Integration` directories to ensure the inclusion of empty directories in the repository.
- These changes prepare the structure for future development of smoke and integration tests, aligning with the expanded testing strategy outlined in previous commits.
…cov workflow

**Details:**
- Deleted `smoke` and `integration` test suites from `phpunit.xml` as part of simplifying the test structure to focus solely on the `unit` suite.
- Updated the Codecov workflow (`Codecov.yml`) to reflect this change by specifying the `suits` parameter as `["unit"]`.
- Removed `.gitkeep` files from `tests/Integration` and `tests/Smoke` directories, as these test categories are no longer included.

This cleanup streamlines test management and aligns testing and coverage workflows with the current project focus.
**Details:**
- Corrected a typo in the `Codecov.yml` file, changing `suits` to `suites` under the Codecov configuration.
- Ensures proper functionality and alignment with the expected configuration syntax.
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

…se branch

**Details:**
- Added badges for PHPStan, PHPUnit, and Codecov workflows to the README file.
- Linked the badges to their respective GitHub Actions workflows and Codecov report for the `architecture/error-exception-base` branch.
- Enhances visibility into CI status and coverage metrics directly from the project documentation.
…bs with enhanced `ValueObject` exception handling tests

**Details:**
- Introduced `DummyVOInvalidGuardException` stub for validating value objects with guard clause testing.
- Added `DummyNotFireHubException` to simulate custom exception scenarios in tests.
- Extended `ValueObjectTest` with a test case for invalid guard clause validation, expecting `ValueObjectException`.
- Updated `DummyStringVO` and `DummyIntVO` to include new FireHub-native exception types in their constructors.
- These changes expand test coverage, ensure stricter validation, and align tests with the project's exception hierarchy structure.
@dieselxxx dieselxxx moved this from Draft to Done in 📌 Core Development: v0 → v1 Jun 25, 2026
@dieselxxx dieselxxx marked this pull request as ready for review June 25, 2026 11:59
@dieselxxx dieselxxx requested review from a team as code owners June 25, 2026 11:59
@dieselxxx dieselxxx merged commit f9b4c60 into develop Jun 25, 2026
8 checks passed
@dieselxxx dieselxxx deleted the architecture/error-exception-base branch June 25, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: Architecture Represent changes that define, enforce, or modify the structural design of the FireHub ecosystem.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Define Core Error & Exception Abstraction Layer

2 participants