PHPackages                             spencer-mortensen/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. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. spencer-mortensen/exceptions

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

spencer-mortensen/exceptions
============================

Catch fatal errors and warnings that would otherwise be difficult to handle

6.0.3(1y ago)041.5k↓53.3%4LGPL-3.0-or-laterPHPPHP &gt;=5.6.0

Since Jan 1Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Spencer-Mortensen/exceptions)[ Packagist](https://packagist.org/packages/spencer-mortensen/exceptions)[ Docs](https://github.com/spencer-mortensen/exceptions)[ RSS](/packages/spencer-mortensen-exceptions/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (19)Used By (4)

Exceptions
==========

[](#exceptions)

This project is available as a Composer Package:
[spencer-mortensen/exceptions](https://packagist.org/packages/spencer-mortensen/exceptions)

Overview
--------

[](#overview)

Error handling in PHP is [complicated](https://spencermortensen.com/articles/php-error-handling/), but this library makes it bullet-proof: Create a method to handle exceptions (e.g. `$handler->handle($throwable);`) and you're good to go!

This library converts all PHP notices, warnings, and errors into exceptions, so you can handle them. It also works on any thrown exceptions that make it up to the global scope. It even catches most of the fatal errors, which would otherwise be impossible to handle.

Usage
-----

[](#usage)

Example 1. Enable error handling for the entire program:

```
new ErrorHandling($errorHandler, E_ALL);
```

Example 2. Enable error handling ONLY for your portion of the code:

```
try {
	ErrorHandling::on();
	...
} finally {
	ErrorHandling::off();
}
```

This converts PHP notices, warnings, and errors into catchable exceptions, but *only* for the duration of the try/catch block.

Example 3. Show the built-in PHP STDERR messages, so you can see errors while you're working on your error handler. If you're working on your error handler, and you're getting a blank screen, use this:

```
new ErrorHandling($errorHandler, E_ALL, false);
```

When you're finished, set everything back to normal:

```
new ErrorHandling($errorHandler, E_ALL);
```

See the [example](https://github.com/spencer-mortensen/exceptions/tree/master/example) area for working code and ideas.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance46

Moderate activity, may be stable

Popularity28

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity67

Established project with proven stability

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

Recently: every ~501 days

Total

18

Last Release

413d ago

Major Versions

1.0.0 → 2.0.02018-01-05

2.0.2 → 3.0.02018-06-27

3.2.2 → 4.0.02019-08-21

4.0.1 → 5.0.02019-11-18

5.0.0 → 6.0.02022-12-27

PHP version history (2 changes)1.0.0PHP &gt;=5.3.0

3.0.0PHP &gt;=5.6.0

### Community

Maintainers

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

---

Top Contributors

[![spencer-mortensen](https://avatars.githubusercontent.com/u/2017476?v=4)](https://github.com/spencer-mortensen "spencer-mortensen (25 commits)")

---

Tags

exceptions

### Embed Badge

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

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

###  Alternatives

[lsrur/inspector

Laravel Inspector, debugging and profiling tools for Web Artisans

23441.1k](/packages/lsrur-inspector)[vasek-purchart/tracy-blue-screen-bundle

This bundle lets you use the Tracy's debug screen in combination with the the default profiler in your Symfony application.

1178.4k](/packages/vasek-purchart-tracy-blue-screen-bundle)

PHPackages © 2026

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