CoreError

Filepath: phork/php/core/CoreError.class.php

The CoreError class is Phork's custom error handler that's set up in the bootstrap. Any system errors or errors generated with trigger_error() go through the error handler class. Fatal application errors that are a result of incorrect code (rather than errors that result from something the user did) should use the CoreException class.

PHP's error reporting must include E_USER_NOTICE so that Phork's custom errors can be handled properly. The error reporting level is set in the front controller (index.php).

Errors can also be logged to a file depending on the $arrConfig['ErrorLogNotice'], $arrConfig['ErrorLogWarning'], and $arrConfig['ErrorLogError'] settings in the global configuration file.

The error object also supports error groups. Groups are used when you want to track errors from a particular subset of code.


Basic Example

trigger_error('There was an error');
$arrErrors = AppRegistry::get('Error')->flushErrors();

Group Example

$objError = AppRegistry::get('Error');
$objError->startGroup('myErrors');

trigger_error('There was an error');

if ($intGroupErrors = $objError->endGroup('myErrors')) {
    $arrErrors = $objError->getGroupErrors('myErrors');
    $objError->clearGroupErrors('myErrors');
}