hoa/exception
Hoa\Exception is a PHP library for richer exception handling. It treats exceptions as objects with formatted, parameterized messages, supports exception groups, chaining, and customizable rendering, making error reporting clearer and more structured in PHP applications.
Architecture fit
hoa/exception is a standalone exception-construction library, not a framework integration. It does not hook into Laravel's Illuminate\Foundation\Exceptions\Handler; it only changes the shape and type of the objects you throw.Hoa\Exception\Exception::chain), aggregation (Hoa\Exception\Group, which is IteratorAggregate/Countable/ArrayAccess), lazy construction (Hoa\Exception\Idle), and retry semantics.Handler::report/render, Reportable/Renderable contracts, ValidationException + MessageBag for aggregation, and the retry() helper for backoff. Net-new capability is narrow — roughly one marker interface and one aggregate class.Integration feasibility
Hoa\Consistency, which pulls a transitive Hoa subgraph (consistency, possibly protocol/ustring) and drags its maintenance debt along.object, 7.4 typed properties, 8.0 unions, 8.1 never, and 8.2 dynamic-property deprecation. Compatibility with the PHP 8.x versions modern Laravel requires must be proven, not assumed.Hoa\Exception\Throwable interface alongside \Exception. Because Hoa exceptions extend \Exception, Laravel's \Throwable catches will work — but dontReport, $internalDontReport, WithExceptions mapping, and withoutExceptionHandling() in tests will not know about Hoa-specific semantics without explicit wiring.SerializesModels → failed_jobs → Horizon/Sentry payloads.Technical risk: high
Group and deep chains can truncate or fail to serialize, degrading diagnostics at exactly the moment they matter.Key questions
ValidationException, retry(), and a ~100-line AggregateException cover it?report() → queue serialize → failed() → Sentry/Horizon payload?Stack fit
Migration path
composer require hoa/exception in a throwaway app; run the PHP/Laravel matrix; assert autoload, inheritance, handler behavior, and queue round-trip.App\Exceptions\AggregateException and App\Exceptions\RetryableException (marker interface). Consumers depend only on app types; Hoa becomes a private implementation detail.Compatibility notes
hoa:// stream wrapper and Hoa\Consistency bootstrap do not collide with Flysystem/S3/phar:// wrappers registered at boot.expectException(\Throwable::class) paths behave; Hoa's interfaces won't satisfy native type-hints.Sequencing
Maintenance
Support
chain, retry, silent, and Group are non-idiomatic, sparsely documented, and unfamiliar to Laravel engineers.Scaling
Idle is used for control-flow-style cases.Group exceptions and deep chains can produce oversized log/Sentry payloads and exceed ingestion limits. Truncation and sampling must be added in the handler.failed_jobs rows.Failure modes
{message, errors, exception} contract.Hoa\Consistency bootstrap interferes with stream wrappers or global state → intermittent, hard-to-reproduce failures.Ramp-up
How can I help you explore Laravel packages today?