PHPackages                             codemonster-ru/errors - 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. [Framework](/categories/framework)
4. /
5. codemonster-ru/errors

ActiveLibrary[Framework](/categories/framework)

codemonster-ru/errors
=====================

Universal exception and HTTP error handling package for PHP applications. Developed for the Codemonster ecosystem (Annabel framework).

v1.2.0(4mo ago)0771MITPHPPHP &gt;=8.2CI passing

Since Nov 9Pushed 4mo agoCompare

[ Source](https://github.com/codemonster-ru/errors)[ Packagist](https://packagist.org/packages/codemonster-ru/errors)[ Docs](https://github.com/codemonster-ru/errors)[ RSS](/packages/codemonster-ru-errors/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (4)Used By (1)

codemonster-ru/errors
=====================

[](#codemonster-ruerrors)

[![Latest Version on Packagist](https://camo.githubusercontent.com/9690b7998ae920284ce5b0875c03365afbbab6a532dc018385afcca5fa887e96/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f64656d6f6e737465722d72752f6572726f72732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/codemonster-ru/errors)[![Total Downloads](https://camo.githubusercontent.com/598755f28bf9896f1e8f42a3adfb321996d64520c78c9655740b2c54ee155500/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636f64656d6f6e737465722d72752f6572726f72732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/codemonster-ru/errors)[![License](https://camo.githubusercontent.com/51012a0860fe88f7437dd10f27ec7bfc4d6e9768f30c2a85081fa7150cd2faa8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f636f64656d6f6e737465722d72752f6572726f72732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/codemonster-ru/errors)[![Tests](https://github.com/codemonster-ru/errors/actions/workflows/tests.yml/badge.svg)](https://github.com/codemonster-ru/errors/actions/workflows/tests.yml)

Universal package for handling exceptions and HTTP errors.

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

[](#installation)

```
composer require codemonster-ru/errors
```

Quick Start
-----------

[](#quick-start)

It can be used as part of a framework or on its own in any PHP project.

### Example 1. Minimal use

[](#example-1-minimal-use)

```
use Codemonster\Errors\Handlers\SmartExceptionHandler;

require __DIR__ . '/vendor/autoload.php';

$handler = new SmartExceptionHandler();

set_exception_handler(function (Throwable $e) use ($handler) {
    $response = $handler->handle($e);

    if (php_sapi_name() !== 'cli') {
        http_response_code($response->getStatusCode());

        echo (string) $response;
    } else {
        fwrite(STDERR, (string) $response . PHP_EOL);
    }
});

throw new RuntimeException('Something went wrong!');
```

When you run it, you'll get a neat HTML page (or a text fallback in the CLI), with error information and the correct HTTP code.

### Example 2. Integration with a View renderer (e.g. from a framework)

[](#example-2-integration-with-a-view-renderer-eg-from-a-framework)

```
use Codemonster\Errors\Handlers\SmartExceptionHandler;
use Codemonster\View\View;

$view = new View(...);
$viewRenderer = fn(string $template, array $data) => $view->render($template, $data);
$handler = new SmartExceptionHandler($viewRenderer, debug: true);

try {
    throw new RuntimeException('Demo error');
} catch (Throwable $e) {
    $response = $handler->handle($e);

    echo $response;
}
```

Template structure
------------------

[](#template-structure)

```
resources/views/errors/
- generic.php # error page for production
- debug.php # debug page for developers
- 404.php # optional, per-status page
- 500.php # optional, per-status page

```

Any 3-digit HTTP status file will be used when present. You can override the template base path with the third constructor argument. Constructor: `new SmartExceptionHandler(?callable $viewRenderer = null, bool $debug = false, ?string $templatePath = null)`

Example:

```
$handler = new SmartExceptionHandler(
    viewRenderer: null,
    debug: false,
    templatePath: __DIR__ . '/resources/views/errors'
);
```

Behavior
--------

[](#behavior)

- Uses `errors.debug` when `debug: true`.
- Uses `errors.` when a status-specific template exists.
- Falls back to `errors.generic`, then to a plain-text response.
- In debug mode, renderer exceptions are rethrown.

Testing
-------

[](#testing)

You can run tests with the command:

```
composer test
```

Author
------

[](#author)

[**Kirill Kolesnikov**](https://github.com/KolesnikovKirill)

License
-------

[](#license)

[MIT](https://github.com/codemonster-ru/errors/blob/main/LICENSE)

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance75

Regular maintenance activity

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

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 ~27 days

Total

3

Last Release

136d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a22c460130c82eca5da633a388faa81adf7e63558a2ae1e34441e6624ec2ad15?d=identicon)[KolesnikovKirill](/maintainers/KolesnikovKirill)

---

Top Contributors

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

---

Tags

annabelcodemonstererrorsexceptionsframeworkhandlerhttpphphttpphpframeworkerrorsexceptionshandlercodemonsterannabel

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/codemonster-ru-errors/health.svg)

```
[![Health](https://phpackages.com/badges/codemonster-ru-errors/health.svg)](https://phpackages.com/packages/codemonster-ru-errors)
```

###  Alternatives

[utopia-php/framework

A simple, light and advanced PHP HTTP framework

295618.4k9](/packages/utopia-php-framework)[utopia-php/http

A simple, light and advanced PHP HTTP framework

2962.8k2](/packages/utopia-php-http)

PHPackages © 2026

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