Skip to content
Permalink
Browse files

Update error configuration in App skeleton.

  • Loading branch information...
markstory committed Aug 20, 2013
1 parent 13d4a2e commit 263ac6c244f9767a21956442cea850866cda9f88
Showing with 30 additions and 44 deletions.
  1. +30 −44 App/Config/error.php
@@ -8,64 +8,50 @@
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.Config
* @since CakePHP(tm) v3.0.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace App\Config;
use Cake\Core\Configure;
use Cake\Error\ErrorHandler;
use Cake\Console\ConsoleErrorHandler;
/**
* 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 Cake Log when debug = 0.
* Configure the Error and Exception handlers used by your application.
*
* Options:
* By default errors are displayed using Debugger, when debug > 0 and logged by
* Cake\Log\Log when debug = 0.
*
* - `handler` - callback - The callback to handle errors. You can set this to any callable type,
* including anonymous functions.
* - `consoleHandler` - callback - The callback to handle errors. You can set this to any callable type,
* including anonymous functions.
* - `level` - int - The level of errors you are interested in capturing.
* - `trace` - boolean - Include stack traces for errors in log files.
*
* @see ErrorHandler for more information on error handling and configuration.
*/
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,
* ErrorHandler::handleException() is used. It will display a HTML page for the exception, and
* while debug > 0, framework errors like Missing Controller will be displayed. When debug = 0,
* framework errors will be coerced into generic HTTP errors.
* In CLI environments exceptions will be printed to stderr with a backtrace.
* In web environments an HTML page will be displayed for the exception.
* While debug > 0, framework errors like Missing Controller will be displayed.
* When debug = 0, framework errors will be coerced into generic HTTP errors.
*
* Options:
*
* - `handler` - callback - The callback to handle exceptions. You can set this to any callback type,
* including anonymous functions.
* - `renderer` - string - The class responsible for rendering uncaught exceptions. If you choose a custom class you
* should place the file for that class in app/Lib/Error. This class needs to implement a render method.
* - `log` - boolean - Should Exceptions be logged?
* - `skipLog` - array - list of exceptions to skip for logging. Exceptions that
* - `errorLevel` - int - The level of errors you are interested in capturing.
* - `trace` - boolean - Whether or not backtraces should be included in
* logged errors/exceptions.
* - `exceptionRenderer` - string - The class responsible for rendering
* uncaught exceptions. If you choose a custom class you should place
* the file for that class in app/Lib/Error. This class needs to implement a render method.
* - `skipLog` - array - List of exceptions to skip for logging. Exceptions that
* extend one of the listed exceptions will also be skipped for logging.
* Example: `'skipLog' => array('Cake\Error\NotFoundException', 'Cake\Error\UnauthorizedException')`
*
* @see ErrorHandler for more information on exception handling and configuration.
* @see ErrorHandler for more information on error handling and configuration.
*/
Configure::write('Exception', [
'handler' => 'Cake\Error\ErrorHandler::handleException',
'consoleHandler' => 'Cake\Console\ConsoleErrorHandler::handleException',
'renderer' => 'Cake\Error\ExceptionRenderer',
'log' => true
]);
$options = [
'errorLevel' => E_ALL & ~E_DEPRECATED,
'exceptionRenderer' => 'Cake\Error\ExceptionRenderer',
'skipLog' => [],
'log' => true,
'trace' => true,
];
/**
* Once configured, set the error/exception handlers to PHP's default handlers.
*/
Configure::setErrorHandlers();
if (php_sapi_name() == 'cli') {
$errorHandler = new ConsoleErrorHandler($options);
} else {
$errorHandler = new ErrorHandler($options);
}
$errorHandler->register();

0 comments on commit 263ac6c

Please sign in to comment.
You can’t perform that action at this time.