solis / phpbreaker
This package contains a set of exceptions shared across Solis components
Installs: 2 895
Dependents: 9
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 1
Open Issues: 0
Requires
- php: ^7.0
- solis/foundation: v0.*
Requires (Dev)
- codacy/coverage: dev-master
- phpunit/phpunit: ~v6.0
- squizlabs/php_codesniffer: 3.*
README
This package contains a set of exceptions shared across Solis components.
Install
The best way to use this component is through Composer
composer require solis/phpbreaker
Usage
The simplest usage is to thrown a implementation of Solis\Breaker\ExceptionInterface.
use Solis\Breaker\ExceptionInterface; use Solis\Exceptions\RuntimeException; try { thrown new RuntimeException('something bad here', 500); } catch (ExceptionInterface $e){ echo $e->getMessage(); // you can get a representation of the exception as array, containing an error and a debug entry // $e->toArray(); // same representation as before but in json format // $e->toJson(); // get only the error entry as json representation // $e->getErrorAsJson(); // get only the debug entry as json representation // $e->getDebugAsJson(); // its possible to set custom data to the error entry of the exception // $e->getError()->setEntry($entry, $data); // the same for the debug entry // $e->getDebug()->setEntry($entry, $data); }
All exceptions implemented in this package extends one of the SPL Exceptions. So its possible to catch normally with catch \Exception.
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
$ composer test
Contributing
All feedback / bug reports / pull requests are welcome.
License
The MIT License (MIT). Please see License File for more information.