Skip to content

Commit

Permalink
Make error handling use Configure again.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Sep 18, 2012
1 parent dcae30a commit 5d2cef2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
18 changes: 8 additions & 10 deletions App/Config/error.php
Expand Up @@ -32,12 +32,12 @@
*
* @see ErrorHandler for more information on error handling and configuration.
*/
$error = array(
Configure::write('Error', [
'handler' => 'Cake\Error\ErrorHandler::handleError',
'consoleHandler' => 'Cake\Console\ConsoleErrorHandler::handleError',
'level' => E_ALL & ~E_DEPRECATED,
'trace' => true
);
]);

/**
* Configure the Exception handler used for uncaught exceptions. By default,
Expand All @@ -55,16 +55,14 @@
*
* @see ErrorHandler for more information on exception handling and configuration.
*/
$exception = array(
Configure::write('Exception', [
'handler' => 'Cake\Error\ErrorHandler::handleException',
'consoleHandler' => 'Cake\Console\ConsoleErrorHandler::handleException',
'renderer' => 'Cake\Error\ExceptionRenderer',
'log' => true
);
]);

Configure::setErrorHandlers(
$error,
$exception
);

unset($error, $exception);
/**
* Once configured, set the error/exception handlers to PHP's default handlers.
*/
Configure::setErrorHandlers();
7 changes: 3 additions & 4 deletions App/Config/session.php
Expand Up @@ -14,7 +14,7 @@
*/
namespace App\Config;

use Cake\Model\Datasource\Session;
use Cake\Core\Configure;

/**
* Session configuration.
Expand Down Expand Up @@ -52,8 +52,7 @@
*
* To use database sessions, run the app/Config/Schema/sessions.php schema using
* the cake shell command: cake schema create Sessions
*
*/
Session::config(array(
Configure::write('Session', [
'defaults' => 'php'
));
]);
12 changes: 8 additions & 4 deletions lib/Cake/Core/Configure.php
Expand Up @@ -348,24 +348,28 @@ public static function clear() {
static::$_values = array();
return true;
}

/**
* Set the error and exception handlers.
* Set the error and exception handlers using the native default handlers.
*
* Uses data already stored in Configure.
*
* @param array $error The Error handling configuration.
* @param array $exception The exception handling configuration.
* @return void
*/
public static function setErrorHandlers($error, $exception) {
public static function setErrorHandlers() {
$level = -1;
$error = static::read('Error');
if (isset($error['level'])) {
error_reporting($error['level']);
$level = $error['level'];
}
if (!empty($error['handler'])) {
set_error_handler($error['handler'], $level);
}
$exception = static::read('Exception');
if (!empty($exception['handler'])) {
set_exception_handler($exception['handler']);
}
}

}

0 comments on commit 5d2cef2

Please sign in to comment.