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.2kpropietaryPHP

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 1mo ago

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

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

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

3492d 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

[ecotone/ecotone

Supporting you in building DDD, CQRS, Event Sourcing applications with ease.

558549.8k17](/packages/ecotone-ecotone)[civicrm/civicrm-core

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

728272.9k20](/packages/civicrm-civicrm-core)[j0k3r/php-readability

Automatic article extraction from HTML

186808.8k6](/packages/j0k3r-php-readability)[symfony/ai-platform

PHP library for interacting with AI platform provider.

51927.7k136](/packages/symfony-ai-platform)[symfony/ai-agent

PHP library for building agentic applications.

30536.7k44](/packages/symfony-ai-agent)[spomky-labs/pwa-bundle

Progressive Web App Manifest Generator Bundle for Symfony.

6144.4k1](/packages/spomky-labs-pwa-bundle)

PHPackages © 2026

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