letsface / php-error-handler
Exception handler for php to customise behavior given a specific exception code
Installs: 26
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 7
Forks: 0
Open Issues: 0
pkg:composer/letsface/php-error-handler
Requires
- pimple/pimple: ~1.0
Requires (Dev)
- phpunit/phpunit: ^4.7
This package is not auto-updated.
Last update: 2026-02-04 16:54:52 UTC
README
Exception handler for php to customise behavior given a specific exception code
Usage
Custom handler
$handler = new \Letsface\ExceptionHandler(); $handler->listen('123', function() { return 'foo'; }); try { throw new \MyException('', '123'); } catch(\Exception $e) { // will echo "foo"; echo $handler->handle($e); }
Throw an exception
$handler = new \Letsface\ExceptionHandler(); $handler->throws('123', new \AnotherException('My new message', 'NEWCODE')); try { throw new \MyException('', '123'); } catch(\Exception $e) { // will throw "\AnotherException"; $handler->handle($e); }
Rethrow the exception
$handler = new \Letsface\ExceptionHandler(); $handler->rethrow('123'); try { throw new \MyException('', '123'); } catch(\Exception $e) { // will throw $e; $handler->handle($e); }