Nette Debugger (or Laďenka by it's Czech beautiful name) is very helpful when solving problems, because it displays exceptions in a lovely way. Sometimes it's not enough though and you'd like to see even more, which is absolutely relevant and possible.
Exception details
You can register panels, which are just callbacks executed
when an uncaught exception is thrown. Standard exceptions have just a
message, which is often enough to understand the problem, but may not
be in all cases. For example in my app, when an ForbiddenException
is thrown, it contains not only an error message, but also an
array or required privileges (which weren't met). These details
are not displayed by default, which is however not a problem for us. We can
register a panel to display details:
use Nette\Diagnostics\Debugger;
Debugger::$blueScreen->addPanel(function(\Exception $ex = null) {
if(method_exists($ex, 'getDetails')) {
return array(
'tab' => 'Details',
'panel' => Debugger::dump($ex->getDetails(), true),
);
}
});
From now on, every-time an exception with method getDetails() is
thrown, these details will be displayed before the call stack. So you know,
which privileges weren't met, and when angry customer calls you a minute later,
you can just adjust his profile for his happiness.
Environmental panels
In my app, I want also some more info about the environment where the
exception occurred. I want details of the user logged-in to the app, config
file which have been processed and probably also info about cluster node, which
processed the request. These panels should be displayed in the bottom of
bluescreen, in a similar way HTTP request a HTTP
response are displayed. This can be achieved by returning bottom =
true from the callback:
Debugger::$blueScreen->addPanel(function() use($context) {
static $displayed = false;
if($displayed) return; // show only once if exception has parents
$displayed = true;
return array(
'tab' => 'User details',
'panel' => Debugger::dump($context->user, true),
);
});
Summary
Make sure that you have all info you need to process an exception log when it happens; add your app specific panels to Nette Debugger.

