There is no license information available for the latest version (v1.0.2) of this package.

A stacked error handling library

v1.0.2 2014-09-19 16:01 UTC

This package is not auto-updated.

Last update: 2023-07-31 19:37:27 UTC


README

Build Status Coverage Status

This library makes it easier to handle exceptions of different types in different ways.

This library automatically converts errors triggered within your code to an instance of ErrorException which is thrown.

Installation

Install via composer

{
    "require": {
        "joegreen0991/error": "1.*"
    }
}

Usage

Simply instantiate the class and it will automatically apply an error handler to convert errors to exceptions, using set_error_handler.

It will also create an exception handler using set_exception_handler which checks for closures handling the type of exception that has been thrown.

$handler = new Error\Handler();

$handler->error(function(HttpRouteNotFoundError $e)
{
    echo "Route does not exist";

})->error(function(PDOException $e)
{
    echo "Database is down!";

})->error(function(ErrorException $e)
{
    echo "A notice level error has occurred";

})->error(function(Exception $e)
{
    echo "Whoops - Something has gone terribly wrong";
});