arabcoders/errors

Error Handling Library

v1.7.2 2019-09-15 11:34 UTC

This package is auto-updated.

Last update: 2024-04-15 22:05:40 UTC


README

Build Status

Error Handling Library, This library can handle logging and displaying of the errors, you can also register listener for special error cases such as if you want to handle specific error/exception in different way, or want to extend/replace the Structured data, It can log to multiple services defined by the user, it can also handle different output streams, there is also Policy class to handle Different requirement of logging/displaying/exiting of the application.

Im working to support Psr3 there is minimal support right now with Logger Class and PSR3 abstract class, we may have to refactor major parts to be compatiable with it.

Install

Via Composer

$ composer require arabcoders/errors

Usage Example.

<?php

require __DIR__ . '/../../autoload.php';

$error = new \arabcoders\errors\Error();

$error->addLogger( 'default', new \arabcoders\errors\Logging\Syslog() )
      ->setOutput( new \arabcoders\errors\Output\HTML() );

//-- or you can use (bool)true in constructor to init default logger/output like
$error = new \arabcoders\errors\Error(true);

trigger_error( 'test Warning', \E_USER_WARNING);

To run Tests.

cd vendor/arabcoders/errors;
composer update
./vendor/bin/phpunit tests/