mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Adding level to the core.php file, this lets you choose which error levels you are interested in for your application.
Removing hardcoded error_reporting levels in Configure.
This commit is contained in:
parent
561fe7b91f
commit
a621ac1ba3
2 changed files with 14 additions and 9 deletions
|
@ -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
|
||||
));
|
||||
|
||||
/**
|
||||
|
|
|
@ -106,6 +106,9 @@ class Configure {
|
|||
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']);
|
||||
}
|
||||
|
@ -164,16 +167,13 @@ class Configure {
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue