blacksmith-project / dr-watson
This package is abandoned and no longer maintained.
No replacement package was suggested.
A PHP library enhancing `\Exception`.
v0.3.0
2019-01-12 15:21 UTC
Requires
- myclabs/php-enum: ^1.6
Requires (Dev)
- escapestudios/symfony2-coding-standard: ^3.4
- mnapoli/pretty: ^1.0
- phpstan/phpstan: ^0.10
- phpunit/phpunit: ^7.3
- squizlabs/php_codesniffer: ^3.3
README
A PHP library enhancing \Exception
.
Why ?
\Exception
does not provide enough information to debug easily.
Indeed, stacktrace can sometime be hard to understand, and message can be insufficient.
DrWatson
is the developper personal investigation assistant, providing
type, suspect and help.
Installation:
composer require blacksmith-project/dr-watson
How to use it:
You can throw a DrWatson::report
.
- type should tell you if the exception is an input issue, domain or internal.
That will help you to know quickly who failed and what quick deduction you can make:
- Input = User failed, let him know.
- Domain = Further investigation on the code is necessary.
- Internal = Inspect the code, but maybe some infrastructure failed (BDD for example).
- suspect should help you target quickly to the right place to look at.
- help should explain to you why it failed. Some business logic can be exposed here, to help you narrow the issue down.
Example:
if (!$this->isValid($email)) { throw new DrWatson( ExceptionType::INPUT(), 'email', 'It seems that User provided an invalid email. Please make sure a typo was not made.', 'input.email.invalid' ); }