Chapter 11. Error handling and debugging

Table of Contents

Handling errors
Debugging

Handling errors

By default, Atomik won't catch any exceptions or errors, PHP's normal behavior preval. However it is possible to enable error catching so you can display an error page to the user or error reports while developing.

The “atomik/catch_errors” configuration key must be set to true for Atomik to catch errors. Errors and exceptions are treated the same way.

By default, an error report will be displayed. The report can be hidden for security purpose by setting false to the “atomik/display_errors” configuration key.

A custom error page can be used as explain in the configuration chapter.

Note

While disabled by default, it is advice to use Atomik's error catching mechanism coupled with a custom error page. This avoid critical information to be displayed to any visitor of your website.

Debugging

Atomik's only provides a simple method named Atomik::debug() which is an alias for var_dump(). However the method output can be hidden by modifying the “debug” configuration key.

Example 11.1. Using Atomik::debug()

				
Atomik::debug($myVar);
Atomik::set('debug', false);
Atomik::debug($myVar2); // no output
Atomik::debug($myVar2, true); // use true to force the output even if debug set to false