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

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

artex/exceptions
================

Artex Software's standard PHP exception library for consistent error handling.

v1.0.0(1y ago)02Apache-2.0PHPPHP &gt;=8.0

Since Jan 26Pushed 1y ago1 watchersCompare

[ Source](https://github.com/artex-agency/Exceptions)[ Packagist](https://packagist.org/packages/artex/exceptions)[ Docs](https://github.com/artex-agency/Exceptions)[ RSS](/packages/artex-exceptions/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

   ![Artex Agency Logo](./docs/media/artex-agency-logo.png)
 **ARTEX EXCEPTIONS**
 Custom PHP Exceptions Library
=====================================================================================================================

[](#------------------------------------artex-exceptions----------------------------custom-php-exceptions-library------------)

**A simple, consistent library for creating and managing exceptions in PHP projects.**

The Artex Standard Exceptions Library provides a basic, flexible way to handle exceptions in your PHP applications. Built to align with good practices, it simplifies exception management and adds a touch of consistency to your projects.

While this library isn't aiming to reinvent the wheel, it serves as a standard tool for PHP projects under the Artex Software ecosystem, ensuring reliability and clarity for developers.

Key Features
------------

[](#key-features)

- **Custom Exceptions**: Extendable exceptions for common use cases (e.g., runtime errors, validation errors, database errors).
- **PSR-4 Compliant**: Easy integration into modern PHP projects.
- **Contextual Data**: Include optional context information for better debugging.
- **Extensibility**: Provides a foundation to build project-specific exceptions.

---

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

[](#installation)

```
composer "require artex/exceptions"
```

Usage
-----

[](#usage)

### Basic Example

[](#basic-example)

```
use Artex\Exceptions\ArtexRuntimeException;

try {
    throw new ArtexRuntimeException("Something went wrong!", 500);
} catch (ArtexRuntimeException $e) {
    echo $e->getMessage();
}
```

### Adding Context to Exceptions

[](#adding-context-to-exceptions)

```
use Artex\Exceptions\ArtexException;

try {
    throw new ArtexException(
        "Validation failed!",
        422,
        ['field' => 'email', 'error' => 'Invalid format']
    );
} catch (ArtexException $e) {
    // Access additional context
    var_dump($e->getContext());
}
```

### Extending Exceptions

[](#extending-exceptions)

You can easily extend any Artex exception to create project-specific exceptions:

```
namespace MyApp\Exceptions;

use Artex\Exceptions\ArtexRuntimeException;

class CustomException extends ArtexRuntimeException
{
    public function __construct(string $message = "", int $code = 0, array $context = [])
    {
        parent::__construct($message, $code, $context);
    }
}
```

### Logging Exceptions

[](#logging-exceptions)

The library can seamlessly log exceptions if a PSR-3 compatible logger is available:

```
use Artex\Exceptions\ArtexRuntimeException;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;

// Set up a PSR-3 logger
$logger = new Logger('example');
$logger->pushHandler(new StreamHandler('php://stdout', Logger::DEBUG));

// Register the logger
ArtexRuntimeException::registerLogger($logger);

try {
    throw new ArtexRuntimeException("Critical failure", 500);
} catch (ArtexRuntimeException $e) {
    // Exception is automatically logged
    echo "Exception logged: " . $e->getMessage();
}
```

---

Available Exceptions
--------------------

[](#available-exceptions)

The library ships with the following prebuilt exceptions:

Exception ClassDescription`ArtexException`Base exception class for all custom exceptions.`ArtexRuntimeException`For runtime errors.`ArtexInvalidArgumentException`For invalid arguments passed to functions.`ArtexLogicException`For logical errors in the application.`ArtexUnexpectedValueException`For unexpected values in operations.`ValidationException`For validation-specific errors.`DatabaseException`For database-related errors.`FileException`For file-related errors.---

Advanced Usage
--------------

[](#advanced-usage)

### Extending Exceptions

[](#extending-exceptions-1)

You can easily extend any Artex exception to create project-specific exceptions:

```
namespace MyApp\Exceptions;

use Artex\Exceptions\ArtexRuntimeException;

class CustomException extends ArtexRuntimeException
{
    public function __construct(string $message = "", int $code = 0, array $context = [])
    {
        parent::__construct($message, $code, $context);
    }
}
```

Requirements
------------

[](#requirements)

- PHP 8.0 or higher

---

Contributing
------------

[](#contributing)

We welcome contributions to the Artex Standard Exceptions Library! If you have an idea, feature request, or find a bug, please open an issue or submit a pull request.

LICENSE
-------

[](#license)

This software is distributed under the **Apache 2.0** License, granting you the freedom to use, modify, and distribute the software, provided you adhere to the terms outlined in the license.

See the [LICENSE](./LICENSE) file for details.

### FOLLOW US

[](#follow-us)

 [ ](https://x.com/artexagency/ "Artex Agency official x/twitter profile")   [ ](https://github.com/artex-agency "Artex Agency official GitHub profile and repository")   [ ](https://www.linkedin.com/company/artexagency "Artex Agency official LinkedIn profile")

  COPYRIGHT © 2025 **ARTEX AGENCY INC.**

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance42

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

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

Unknown

Total

1

Last Release

477d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

artex-agencyartex-softwarecustom-exceptionsexceptionsphpphp-exceptionphp-exceptionsphpexceptionsstandarderror handlingPHP Librarystandard libraryphp exceptionsArtex-SoftwareArtexcustom-exceptionsartex-exceptions

### Embed Badge

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

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

###  Alternatives

[inspector-apm/inspector-symfony

Code Execution Monitoring for Symfony applications.

2830.1k2](/packages/inspector-apm-inspector-symfony)

PHPackages © 2026

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