Moving error and exception handler configuration into Configure, as settings. You can use Error.handler and Exception.handler to define the error and exception handlers for your application.

This commit is contained in:
mark_story 2010-11-14 20:32:44 -05:00
parent 4960b6e7bf
commit e68a1a094e
3 changed files with 16 additions and 17 deletions

View file

@ -34,7 +34,6 @@ require LIBS . 'configure.php';
require LIBS . 'set.php';
require LIBS . 'cache.php';
require LIBS . 'error_handler.php';
set_exception_handler(array('ErrorHandler', 'handleException'));
Configure::bootstrap(isset($boot) ? $boot : true);

View file

@ -103,9 +103,6 @@ class Configure {
if (isset($config['debug']) || isset($config['log'])) {
$reporting = 0;
if (self::$_values['debug']) {
if (!class_exists('Debugger')) {
require LIBS . 'debugger.php';
}
$reporting = E_ALL & ~E_DEPRECATED;
if (function_exists('ini_set')) {
ini_set('display_errors', 1);
@ -113,17 +110,6 @@ class Configure {
} elseif (function_exists('ini_set')) {
ini_set('display_errors', 0);
}
if (isset(self::$_values['log']) && self::$_values['log']) {
if (!class_exists('CakeLog')) {
require LIBS . 'cake_log.php';
}
if (is_integer(self::$_values['log']) && !self::$_values['debug']) {
$reporting = self::$_values['log'];
} else {
$reporting = E_ALL & ~E_DEPRECATED;
}
}
error_reporting($reporting);
}
return true;
@ -381,6 +367,14 @@ class Configure {
)));
}
}
if (!empty(self::$_values['Error']['handler'])) {
set_error_handler(self::$_values['Error']['handler']);
}
if (!empty(self::$_values['Exception']['handler'])) {
set_exception_handler(self::$_values['Exception']['handler']);
}
App::init();
App::build();
if (!include(CONFIGS . 'bootstrap.php')) {

View file

@ -195,9 +195,15 @@ class ErrorHandler {
public static function handleError($code, $description, $file = null, $line = null, $context = null) {
$debug = Configure::read('debug');
if ($debug) {
return Debugger::handleError($code, $description, $file, $line, $context);
if (!class_exists('Debugger')) {
require LIBS . 'debugger.php';
}
return Debugger::showError($code, $description, $file, $line, $context);
} else {
return CakeLog::handleError($code, $description, $file, $line, $context);
if (!class_exists('CakeLog')) {
require LIBS . 'cake_log.php';
}
return CakeLog::logError($code, $description, $file, $line, $context);
}
}