Skip to content

php-enspired/exceptable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

how exceptable!

Exceptables make exceptions exceptional. Exceptables provide some nice utility methods, but the main benefit is having a way to conveniently and quickly organize all the error cases in your application. Exceptables are easy to create and pass details to. They provide access to error info for both humans and code. Exceptables make it easy to extend, add, and maintain error handling code as your application grows.

dependencies

Requires php 7.0 or later.

installation

Recommended installation method is via Composer: simply composer require php-enspired/exceptable.

a quick taste

<?php

use at\exceptable\Handler;
use at\exceptable\Exception as Exceptable;

// a simple Exceptable just for you
class FooException extends Exceptable {

  const UNKNOWN_FOO = 1;

  const INFO = [
    self::UNKNOWN_FOO => [
      'message' => 'unknown foo',
      'tr_message' => "i don't know who, you think is foo, but it's not {foo}"
    ]
  ];
}

throw new FooException(FooException::UNKNOWN_FOO);
// on your screen:
// Fatal error: Uncaught FooException: unknown foo in ...

$handler = new Handler();
$handler
  ->onException(function($e) { error_log($e->getMessage()); return true; })
  ->register();

$context = ['foo' => 'foobedobedoo'];
throw new FooException(FooException::UNKNOWN_FOO, $context);
// in your error log:
// i don't know who, you think is foo, but it's not foobedobedoo

see more in the wiki.

docs

contributing or getting help

I'm on Freenode at #php-enspired, or open an issue on github. Feedback is welcomed as well.

About

Augmented features for exceptions and exception handling.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages