PHPackages                             aatis/error-handler - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. aatis/error-handler

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

aatis/error-handler
===================

Error handler of Aatis

1.1.1(9mo ago)0671PHPPHP ^8.2

Since Jan 15Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/BatMaxou/aatis-error-handler)[ Packagist](https://packagist.org/packages/aatis/error-handler)[ RSS](/packages/aatis-error-handler/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (9)Used By (1)

Aatis Error Handler
===================

[](#aatis-error-handler)

About
-----

[](#about)

Aatis error handler displays errors and exceptions in a more user-friendly way. It also can log them if wanted.

Installation
------------

[](#installation)

```
composer require aatis/error-handler
```

Usage
-----

[](#usage)

### Initialization

[](#initialization)

To initialize the error handler, pass the following parameters to the static `initialize()` method:

- an instance of `ErrorCodeBag` service of this package
- an instance of `ExceptionCodeBag` service of this package
- a logger service that implements the `Psr\Log\LoggerInterface`

```
ErrorHandler::initialize(
    new ErrorCodeBag(),
    new ExceptionCodeBag(),
    new Logger(),
);
```

Note

The logger service is optional. If you do not provide it, the error handler will not log any message.

Note

If needed, Aatis provides a Loger that implements the `Psr\Log\LoggerInterface`. See `aatis/logger` ().

### ErrorCodeBag

[](#errorcodebag)

`ErrorCodeBag` service store 15 error codes corresponding to the 15 error levels of PHP error:

- 1 =&gt; 'E\_ERROR'
- 2 =&gt; 'E\_WARNING'
- 4 =&gt; 'E\_PARSE'
- 8 =&gt; 'E\_NOTICE'
- 16 =&gt; 'E\_CORE\_ERROR'
- 32 =&gt; 'E\_CORE\_WARNING'
- 64 =&gt; 'E\_COMPILE\_ERROR'
- 128 =&gt; 'E\_COMPILE\_WARNING'
- 256 =&gt; 'E\_USER\_ERROR'
- 512 =&gt; 'E\_USER\_WARNING'
- 1024 =&gt; 'E\_USER\_NOTICE'
- 2048 =&gt; 'E\_STRICT'
- 4096 =&gt; 'E\_RECOVERABLE\_ERROR'
- 8192 =&gt; 'E\_DEPRECATED'
- 16384 =&gt; 'E\_USER\_DEPRECATED'

Warning

It is not possible to override any error codes from this bag.

### ExceptionCodeBag

[](#exceptioncodebag)

`ExceptionCodeBag` service store any exception code you want to use in your application. By default, a list with all the 400 and 500 exception codes is provided, but it can be extanded and/or overrided:

- 0 =&gt; 'Basic Error'
- 400 =&gt; 'Bad Request'
- 401 =&gt; 'Unauthorized'
- 402 =&gt; 'Payment Required Experimental'
- 403 =&gt; 'Forbidden'
- 404 =&gt; 'Not Found'
- 405 =&gt; 'Method Not Allowed'
- 406 =&gt; 'Not Acceptable'
- 407 =&gt; 'Proxy Authentication Required'
- 408 =&gt; 'Request Timeout'
- 409 =&gt; 'Conflict'
- 410 =&gt; 'Gone'
- 411 =&gt; 'Length Required'
- 412 =&gt; 'Precondition Failed'
- 413 =&gt; 'Payload Too Large'
- 414 =&gt; 'URI Too Long'
- 415 =&gt; 'Unsupported Media Type'
- 416 =&gt; 'Range Not Satisfiable'
- 417 =&gt; 'Expectation Failed'
- 418 =&gt; 'I'm a teapot'
- 421 =&gt; 'Misdirected Request'
- 422 =&gt; 'Unprocessable Content'
- 423 =&gt; 'Locked'
- 424 =&gt; 'Failed Dependency'
- 425 =&gt; 'Too Early Experimental'
- 426 =&gt; 'Upgrade Required'
- 428 =&gt; 'Precondition Required'
- 429 =&gt; 'Too Many Requests'
- 431 =&gt; 'Request Header Fields Too Large'
- 451 =&gt; 'Unavailable For Legal Reasons'
- 500 =&gt; 'Internal Server Error'
- 501 =&gt; 'Not Implemented'
- 502 =&gt; 'Bad Gateway'
- 503 =&gt; 'Service Unavailable'
- 504 =&gt; 'Gateway Timeout'
- 505 =&gt; 'HTTP Version Not Supported'
- 506 =&gt; 'Variant Also Negotiates'
- 507 =&gt; 'Insufficient Storage'
- 508 =&gt; 'Loop Detected'
- 510 =&gt; 'Not Extended'
- 511 =&gt; 'Network Authentication Required'

### Custom Exception Code

[](#custom-exception-code)

You can add or override any exception codes by creating a custom string enum like the following template:

```
enum ExampleExceptionCodeEnum: string
{
    case _404 = 'Custom Not Found';
    case _30 = 'Custom Error 30';
}
```

Then, pass it into the `ExceptionCodeBag` service constructor.

```
new ExceptionCodeBag([
    ExampleExceptionCodeEnum::class,
    OtherExampleExceptionCodeEnum::class
]);
```

Note

You can pass as many enums as you want.

To precise a specific code to an exception, follow this example:

```
throw new \Exception('My custom message', 30);
```

With Aatis Framework
--------------------

[](#with-aatis-framework)

### Requirements

[](#requirements)

Add `ErrorCodeBag` and `ExceptionCodeBag` services to the `Container`:

```
# In config/services.yaml file :

include_services:
  - 'Aatis\ErrorHandler\Service\ErrorCodeBag'
  - 'Aatis\ErrorHandler\Service\ExceptionCodeBag'
```

### ExceptionCodeBag

[](#exceptioncodebag-1)

If you want to add or override any exception codes from the `ExceptionCodeBag`, do not forget to precise your custom enums to the `ExceptionCodeBag` service:

```
# In config/services.yaml file :

services:
  Aatis\ErrorHandler\Service\ExceptionCodeBag:
    arguments:
      extraExceptionCodeEnums:
        - 'Namespace\To\ExampleExceptionCodeEnum'
        - 'Namespace\To\OtherExampleExceptionCodeEnum'
```

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance58

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~113 days

Recently: every ~139 days

Total

6

Last Release

285d ago

Major Versions

0.2.0 → 1.0.02024-02-06

### Community

Maintainers

![](https://www.gravatar.com/avatar/2f62599db29152e0adf71ca1df468470b4d572bc556a4a634dc6c016157a5044?d=identicon)[Aatis](/maintainers/Aatis)

---

Top Contributors

[![BatMaxou](https://avatars.githubusercontent.com/u/90443919?v=4)](https://github.com/BatMaxou "BatMaxou (4 commits)")

### Embed Badge

![Health badge](/badges/aatis-error-handler/health.svg)

```
[![Health](https://phpackages.com/badges/aatis-error-handler/health.svg)](https://phpackages.com/packages/aatis-error-handler)
```

###  Alternatives

[sentry/sentry

PHP SDK for Sentry (http://sentry.io)

1.9k227.1M273](/packages/sentry-sentry)[rollbar/rollbar

Monitors errors and exceptions and reports them to Rollbar

33723.7M82](/packages/rollbar-rollbar)[illuminate/log

The Illuminate Log package.

6224.3M518](/packages/illuminate-log)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2222.9M248](/packages/open-telemetry-sdk)[open-telemetry/api

API for OpenTelemetry PHP.

1833.0M214](/packages/open-telemetry-api)[pagemachine/typo3-formlog

Form log for TYPO3

23225.3k6](/packages/pagemachine-typo3-formlog)

PHPackages © 2026

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