PHPackages                             granam/exception-hierarchy - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. granam/exception-hierarchy

Abandoned → [granam/exceptions-hierarchy](/?search=granam%2Fexceptions-hierarchy)Library[Testing &amp; Quality](/categories/testing)

granam/exception-hierarchy
==========================

Tests of exceptions hierarchy

5.1.0(5y ago)07.2k5MITPHPPHP &gt;=7.3

Since Mar 29Pushed 5y ago1 watchersCompare

[ Source](https://github.com/granam/exceptions-hierarchy)[ Packagist](https://packagist.org/packages/granam/exception-hierarchy)[ Docs](https://github.com/jaroslavtyc/granam-exceptions-hierarchy)[ RSS](/packages/granam-exception-hierarchy/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (26)Used By (5)

[![Test Coverage](https://camo.githubusercontent.com/9bed09eec0c821edc981c1de020e1f415a99ac1220d6d4c8e54c5f8f1d84dc7d/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6a61726f736c61767479632f6772616e616d2d657863657074696f6e732d6869657261726368792f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/jaroslavtyc/granam-exceptions-hierarchy/coverage)[![License](https://camo.githubusercontent.com/e7828a5e8d55f691e989000c5970835fa3e028e19fc6c6198f4804bb7f147a49/68747470733a2f2f706f7365722e707567782e6f72672f6772616e616d2f657863657074696f6e732d6869657261726368792f6c6963656e7365)](https://packagist.org/packages/granam/exceptions-hierarchy)

Philosophy of exception hierarchy is kind of *you need to know*.

It is important to know what happened. And it happens...

The system fails. Something exceptionable occurs.

Take extra care to get as much description of a problem as possible.

The good way how to achieve that is keep exceptions hierarchy clean and clear.

- follow the project structure.
- make a **root exception marker as an interface**.
- include this interface in **every** exception you produce.
    - by that, anyone can catch exceptions from your project in his project, by a single catch
- learn the difference between logic and runtime exception
    - the base distinction is the logic exception can be detected at compile time (for easy example by IDE), the runtime exception can not - it can occurs only in some combination of data and environment
    - logic exception should occurs if definitely there is an mistake in use of the application
        - that exception tells you: you are using something bad, fix it
    - runtime exception is everything else of course
        - that means: your application is not so robust as should be - fix it or ignore for eternity
    - is it so simple, with clean borders?
        - of course not
        - but like that you can catch all the logic exceptions into folder PersistentBugs and runtime ones into BulletproofFailures

#### In short

[](#in-short)

*Runtime exception* should occurs if something is wrong from **outside**.

*Logic exception* should occurs if something is wrong from **inside**.

### Example of use of Logic and Runtime exception

[](#example-of-use-of-logic-and-runtime-exception)

You built an e-shop with an API.

Your frontend application sends to the API a request for new customer:

- email: dontbotherme

That is not valid email for sure. The frontend check failed and now you are forced to handle that failure.

So lets throw some *Runtime* (like InvalidEmailFormat) exception somewhere inside your code.

Your API of course should catch such exception and returns 400 Bad Request (and descriptive error message).

In another case your application calculates price of an purchase, including discount coupon, volume discount, loyalty discount and... voala, the final price is negative!

That is fatal error for sure, originating inside your application. *Logic* exception (like FinalPriceZeroOrLesser) should be thrown.

The API of course catch that exception and turn it into response 500 Server error (and log that exception for asap fix!) .

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity68

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

Recently: every ~373 days

Total

25

Last Release

1883d ago

Major Versions

1.0.x-dev → 2.0.02015-08-24

2.3.x-dev → 3.0.02017-02-15

3.0.x-dev → 4.0.02017-02-16

4.0.x-dev → 5.0.02019-08-22

PHP version history (5 changes)1.0.0PHP &gt;=5.3

3.0.0PHP &gt;=5.6

4.0.0PHP &gt;=7.0

5.0.0PHP &gt;=7.1

5.1.0PHP &gt;=7.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/7e35d11c9a75584084f0dc0ba1a3b6ff03355777809cbe8eabd20a88ac00f794?d=identicon)[jaroslavtyc](/maintainers/jaroslavtyc)

---

Top Contributors

[![jaroslavtyc](https://avatars.githubusercontent.com/u/2290225?v=4)](https://github.com/jaroslavtyc "jaroslavtyc (61 commits)")

---

Tags

phpexceptionruntimehierarchylogic

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/granam-exception-hierarchy/health.svg)

```
[![Health](https://phpackages.com/badges/granam-exception-hierarchy/health.svg)](https://phpackages.com/packages/granam-exception-hierarchy)
```

###  Alternatives

[vimeo/psalm

A static analysis tool for finding errors in PHP applications

5.8k77.5M6.7k](/packages/vimeo-psalm)[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[letsdrink/ouzo-goodies

Utility classes, test assertions and mocking framework extracted from Ouzo framework.

132617.9k7](/packages/letsdrink-ouzo-goodies)[quizlet/hammock

Hammock is a stand-alone mocking library for Hacklang.

27445.5k](/packages/quizlet-hammock)[doppiogancio/mocked-client

A simple way to mock a client

2174.9k3](/packages/doppiogancio-mocked-client)[robiningelbrecht/phpunit-coverage-tools

PHPUnit coverage tools

1783.0k34](/packages/robiningelbrecht-phpunit-coverage-tools)

PHPackages © 2026

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