Skip to content

Commit

Permalink
Adding level to the core.php file, this lets you choose which error l…
Browse files Browse the repository at this point in the history
…evels you are interested in for your application.

Removing hardcoded error_reporting levels in Configure.
  • Loading branch information
markstory committed Nov 26, 2010
1 parent 561fe7b commit a621ac1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
9 changes: 7 additions & 2 deletions app/config/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,16 @@
/**
* Configure the Error handler used to handle errors for your application. By default
* ErrorHandler::handleError() is used. It will display errors using Debugger, when debug > 0
* and log errors with CakeLog when debug = 0. You can set it to any static method that is built to handle
* errors.
* and log errors with CakeLog when debug = 0.
*
* Options:
*
* - `handler` The callback to handle errors. You can set this to any callback type, including anonymous functions.
* - `level` The level of errors you are interested in capturing.
*/
Configure::write('Error', array(
'handler' => 'ErrorHandler::handleError',
'level' => E_ALL & ~E_DEPRECATED
));

/**
Expand Down
14 changes: 7 additions & 7 deletions cake/libs/configure.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ public static function bootstrap($boot = true) {
if (!empty(self::$_values['Error']['handler'])) {
set_error_handler(self::$_values['Error']['handler']);
}
if (isset(self::$_values['Error']['level'])) {
error_reporting(self::$_values['Error']['level']);
}
if (!empty(self::$_values['Exception']['handler'])) {
set_exception_handler(self::$_values['Exception']['handler']);
}
Expand Down Expand Up @@ -164,16 +167,13 @@ public static function write($config, $value = null) {
}

if (isset($config['debug']) || isset($config['log'])) {
$reporting = 0;
if (self::$_values['debug']) {
$reporting = E_ALL & ~E_DEPRECATED;
if (function_exists('ini_set')) {
if (function_exists('ini_set')) {
if (self::$_values['debug']) {
ini_set('display_errors', 1);
} else {
ini_set('display_errors', 0);
}
} elseif (function_exists('ini_set')) {
ini_set('display_errors', 0);
}
error_reporting($reporting);
}
return true;
}
Expand Down

0 comments on commit a621ac1

Please sign in to comment.