PHPackages                             treehousetim/exception - 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. treehousetim/exception

ActiveProject[Testing &amp; Quality](/categories/testing)

treehousetim/exception
======================

Simple Good Exceptions

v0.0.1(5y ago)0741↓50%1MITPHPPHP ^7.0CI failing

Since Jul 28Pushed 5y agoCompare

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

READMEChangelog (1)Dependencies (2)Versions (2)Used By (1)

[![Unit Tests](https://github.com/treehousetim/exception/workflows/Unit%20Tests/badge.svg)](https://github.com/treehousetim/exception/workflows/Unit%20Tests/badge.svg)

treehousetim/exception
======================

[](#treehousetimexception)

A PHP Exception class to use as a base for exception handling in well structured web apps.

Installing
----------

[](#installing)

`composer require treehousetim/exception`

Using
-----

[](#using)

After installing, create your own class that extends `treehousetim\exception\Exception`.

Each namespace area of your code should implement its own `Exception.php`

Each Exception class should create class constants for relevant codes.

Exceptions are thrown with a variable length parameter list with the code as the very last parameter.

Throwing
--------

[](#throwing)

To throw an exception, you can build up your message with multiple parameters. Place your code as the last parameter. Exception messages are concatenated from the parameters with `PHP_EOL` as the glue.

```
throw new Exception(
	'This',
	'is',
	$lib->getErrorText(),
	'bad',
	Exception::normalError
);
```

Examples
--------

[](#examples)

### Exception class for somefancylibrary

[](#exception-class-for-somefancylibrary)

```
