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

This package is auto-updated.

Last update: 2020-02-12 17:47:22 UTC


README

Scrutinizer Code Quality Code Coverage Build Status

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'
    );
}