Document toolboxDocument toolbox

Error handling

Microbizz uses a custom error handler to grab and send errors by emails to the drift@microbizz.dk email. The error handler is robust and also handles fatal script-crashing errors (except parse errors which cannot be handled).

Basic profiling functions are also provided giving the ability to send an email with the timing of all database queries during script execution.

The error handler is implemented in /include/errorhandler.php/

Error log server

Errors are saved to the shared database, through the method Log::PHPError.

Compatibiliy with PHP errors

It should work with native PHP errors, and still use the PHP error framework (or an extension to this)

Separation of error message and error details

As errors should be groupable there should be a difference between the error message and the error details. An error such as “Could not find file test/file.txt” is hard to group as the file name can change.

Severity of error

It should be possible to report the severity of the error, in greater details than PHP allows (WARNING vs. ERROR).

Easy to use

It should be very simple to trigger an error codewise.

Statistics

The log server itself should be able to report on the following:

  1. How often an error occurs (in a given time frame).

  2. Over how many contracts an error occurs.

  3. Details of specific occurrences of errors.

Error utilities

Recursion detection

A function is available to quickly detect unwanted recursion. To use it simply insert the following line, in the code where you suspect recursion:

catchrecursion($level = 5)

The $level parameter is the maximum allowed recursion level, before the code is halted and the recursion is displayed. Please note: As this function reveals parts of the source code, it should only be used for debug purposes and never left in the code.