PHPackages                             dhii/exception - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. dhii/exception

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

dhii/exception
==============

Standards-compliant exception classes

v0.1-alpha5(8y ago)014.6k[1 issues](https://github.com/Dhii/exception/issues)18MITPHPPHP ^5.4 | ^7.0

Since Jul 29Pushed 8y ago3 watchersCompare

[ Source](https://github.com/Dhii/exception)[ Packagist](https://packagist.org/packages/dhii/exception)[ RSS](/packages/dhii-exception/feed)WikiDiscussions develop Synced today

READMEChangelog (5)Dependencies (8)Versions (7)Used By (18)

Dhii - Exception
================

[](#dhii---exception)

[![Build Status](https://camo.githubusercontent.com/e40194f01778c25c4bd6e8c417ec295b8d091754099a4b5e05293e6252bce3c2/68747470733a2f2f7472617669732d63692e6f72672f446869692f657863657074696f6e2e7376673f6272616e63683d646576656c6f70)](https://travis-ci.org/Dhii/exception)[![Code Climate](https://camo.githubusercontent.com/08c4704bc34b60475c82f9fc610d92f37319b5ee405485e239f1a6a53c49ad9f/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f446869692f657863657074696f6e2f6261646765732f6770612e737667)](https://codeclimate.com/github/Dhii/exception)[![Test Coverage](https://camo.githubusercontent.com/807dcf98080863521ba1cbbb6204f698279f038a0aa88708cc08d3640aba572a/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f446869692f657863657074696f6e2f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/Dhii/exception/coverage)[![Latest Stable Version](https://camo.githubusercontent.com/e3267c2689cd6cb6abcb003459ae2b55d349e637ac60a58c9fae223d19536242/68747470733a2f2f706f7365722e707567782e6f72672f646869692f657863657074696f6e2f76657273696f6e)](https://packagist.org/packages/dhii/exception)[![This package complies with Dhii standards](https://camo.githubusercontent.com/44bbe8c7678c1784cfc53cabce5d3e32fc22a840453c5ed9c08601522fe7c213/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446869692d436f6d706c69616e742d677265656e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/Dhii/dhii)

Standards-compliant exception classes.

Details
-------

[](#details)

This package contains concrete implementations of classes that implement interfaces in [`dhii/exception-interface`](https://packagist.org/packages/dhii/exception-interface). This provides developers with ready-made, standards-compliant classes that can be safely instantiated and `throw`n to signal the various errors. The concrete exceptions will usually have a corresponding factory trait, and the factory methods of those traits are the recommended way of creating new exception instances (after service definition, of course).

Implementations in this package also have the following features aimed to become more standards-compliant:

- A [stringable](https://github.com/Dhii/stringable-interface) is accepted everywhere, where a string can be passed.
- All parameters can be passed `null` to signal default value (which may be not `null`).

Consumers, i.e. code that attempts to `catch`, should not depend on these classes. Instead, consumers should depend on the interfaces of [`dhii/exception-interface`](https://packagist.org/packages/dhii/exception-interface).

Creating New Exceptions
-----------------------

[](#creating-new-exceptions)

Sometimes, there is a need to create a new exception class, such as to implement a new standard (like [`dhii/action-interface`](https://packagist.org/packages/dhii/action-interface)), or perhaps to implement two unrelated interfaces (imagine an object that implements both [`Dhii\Action\ActionInterface`](https://github.com/Dhii/action-interface/blob/develop/src/ActionInterface.php)and [`Mouf\Utils\Action\ActionInterface`](https://github.com/thecodingmachine/utils.action.action-interface/blob/1.0/src/Mouf/Utils/Action/ActionInterface.php)). In this case, implementing some of the features of Dhii exceptions may take an un-necessarily long time. This package provides a way to make creating new exceptions faster.

- If you need to extend a class other than [`Exception`](http://php.net/manual/en/class.exception.php), then [`ExceptionTrait`](https://github.com/Dhii/exception/blob/develop/src/ExceptionTrait.php) helps by combining common traits used by exceptions, which will initialize the class, while normalizing some values. See [`Dhii\Exception\InvalidArgumentException`](https://github.com/Dhii/exception/blob/develop/src/InvalidArgumentException.php)for an example.
- If you need to extend the root [`Exception`](http://php.net/manual/en/class.exception.php), then the quickest way is by instead extending [`Dhii\Exception\AbstractBaseException`](https://github.com/Dhii/exception/blob/develop/src/AbstractBaseException.php). See [`Dhii\Exception\Exception`](https://github.com/Dhii/exception/blob/develop/src/Exception.php) for an example. As demonstrated, all basic initialization and normalization can be achieved by calling `_initBaseException()` in the constructor, after which custom initialization procedure may be added.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~6 days

Total

5

Last Release

3014d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1894e91b32c9f80d8f30a42d360af6983a507f1cf2c621b7c9a0a0de14e011c5?d=identicon)[XedinUnknown](/maintainers/XedinUnknown)

---

Top Contributors

[![XedinUnknown](https://avatars.githubusercontent.com/u/1428973?v=4)](https://github.com/XedinUnknown "XedinUnknown (106 commits)")[![mecha](https://avatars.githubusercontent.com/u/5425482?v=4)](https://github.com/mecha "mecha (5 commits)")

---

Tags

error-handlingfactoriesimplementationstandards-compliant

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dhii-exception/health.svg)

```
[![Health](https://phpackages.com/badges/dhii-exception/health.svg)](https://phpackages.com/packages/dhii-exception)
```

###  Alternatives

[fjogeleit/prometheus-messenger-middleware

Prometheus Middleware for the Symfony Messenger Component

2255.2k](/packages/fjogeleit-prometheus-messenger-middleware)[spatie/craft-ray

Easily debug CraftCMS projects

1638.6k](/packages/spatie-craft-ray)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
