PHPackages                             aivo/exceptions - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. aivo/exceptions

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

aivo/exceptions
===============

Exceptions

1.0.0(9y ago)030.6kpropietaryPHP

Since Oct 25Pushed 9y ago1 watchersCompare

[ Source](https://github.com/Pnoexz/BaseException)[ Packagist](https://packagist.org/packages/aivo/exceptions)[ RSS](/packages/aivo-exceptions/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (3)Used By (0)

Exceptions
==========

[](#exceptions)

**BaseException** is an abstract class.

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

[](#installation)

Run

```
composer require aivo/exceptions
```

Or edit composer.json and add

```
    "require": {
        "aivo/exceptions": "^1"
    }
```

Function Declaration
--------------------

[](#function-declaration)

```
\Aivo\BaseException::__construct ([\Psr\Log\LoggerInterface $logger = null, $previous = null, $previousLevel = null])

```

\####*\\Psr\\Log\\LoggerInterface* **$logger**A [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md) compatible object. If provided, it will call the logger's method matching the error level when the exception is . It's possible to add a logger after the object has been instantiated using *$\\Aivo\\BaseException-&gt;setLogger(\\Psr\\Log\\LoggerInterface $logger)* and *$\\Aivo\\BaseException-&gt;log()*.

\####*\\Exception* **$previous**It is impossible to add a previous exception runtime so it has to be added while creating a new BaseException object.

\####*string* **$previousLevel**If provided, it will log the previous exception provided using this level. This is useful for logging exceptions that do not extend \\Aivo\\BaseException, such as PDOException.

Extending the object
--------------------

[](#extending-the-object)

It is suggested that you create a new class for every message and code you need to send. Each code should also be unique, ideally on a global scope. This is because the error messages could change at any time so applications should not depend on the actual description text.

Catching the object
-------------------

[](#catching-the-object)

```
public function responseException(\Exception $exception, Response $response)
{
    if ($exception instanceof \Aivo\BaseException) {
        $data = $exception->__toArray();
        $httpCode = $exception->getHttpCode();

    } else {
        $data = [
            'class' => get_class($exception),
            'error' => $exception->getCode(),
            'message' => $exception->getMessage(),
        ];
        $httpCode = 409;
    }

    return $response->withJson($data)
                    ->withStatus($httpCode);
}
```

Logging the previous exception
------------------------------

[](#logging-the-previous-exception)

To log a previous exception (provided in the constructor), simply add a third parameter with the desired level. Level has to be PSR-3 compliant. Example:

```
try {
    throw new \Exception('Super secreta');
}
catch (\Exception $e) {
    throw new \Aivo\Exceptions\Word\NotFound(
        $this->logger(),
        $e,
        \Aivo\BaseException::ERROR
    );
}
```

Author
------

[](#author)

Matias Pino -

This project uses [Semantic Versioning 2.0.0](http://semver.org/)

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity64

Established project with proven stability

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

Total

2

Last Release

3538d ago

### Community

Maintainers

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

### Embed Badge

![Health badge](/badges/aivo-exceptions/health.svg)

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

###  Alternatives

[symfony/lock

Creates and manages locks, a mechanism to provide exclusive access to a shared resource

514139.2M689](/packages/symfony-lock)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

564576.7k52](/packages/ecotone-ecotone)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)[illuminate/broadcasting

The Illuminate Broadcasting package.

7127.2M208](/packages/illuminate-broadcasting)[logiscape/mcp-sdk-php

Model Context Protocol SDK for PHP

368116.8k12](/packages/logiscape-mcp-sdk-php)

PHPackages © 2026

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