* CErrorHandler handles uncaught PHP errors and exceptions.
* ErrorHandler handles uncaught PHP errors and exceptions.
*
*
* It displays these errors using appropriate views based on the
* It displays these errors using appropriate views based on the
* nature of the error and the mode the application runs at.
* nature of the error and the mode the application runs at.
* It also chooses the most preferred language for displaying the error.
* It also chooses the most preferred language for displaying the error.
*
*
* CErrorHandler uses two sets of views:
* ErrorHandler uses two sets of views:
* <ul>
* <ul>
* <li>development views, named as <code>exception.php</code>;
* <li>development views, named as <code>exception.php</code>;
* <li>production views, named as <code>error<StatusCode>.php</code>;
* <li>production views, named as <code>error<StatusCode>.php</code>;
...
@@ -33,7 +32,7 @@ Yii::import('CHtml',true);
...
@@ -33,7 +32,7 @@ Yii::import('CHtml',true);
* For security reasons, they only display the error message without any
* For security reasons, they only display the error message without any
* sensitive information.
* sensitive information.
*
*
* CErrorHandler looks for the view templates from the following locations in order:
* ErrorHandler looks for the view templates from the following locations in order:
* <ol>
* <ol>
* <li><code>themes/ThemeName/views/system</code>: when a theme is active.</li>
* <li><code>themes/ThemeName/views/system</code>: when a theme is active.</li>
* <li><code>protected/views/system</code></li>
* <li><code>protected/views/system</code></li>
...
@@ -44,153 +43,170 @@ Yii::import('CHtml',true);
...
@@ -44,153 +43,170 @@ Yii::import('CHtml',true);
* The property {@link maxSourceLines} can be changed to specify the number
* The property {@link maxSourceLines} can be changed to specify the number
* of source code lines to be displayed in development views.
* of source code lines to be displayed in development views.
*
*
* CErrorHandler is a core application component that can be accessed via
* ErrorHandler is a core application component that can be accessed via
* {@link CApplication::getErrorHandler()}.
* {@link CApplication::getErrorHandler()}.
*
*
* @property array $error The error details. Null if there is no error.
* @property array $error The error details. Null if there is no error.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$
* @since 2.0
* @package system.base
* @since 1.0
*/
*/
classCErrorHandlerextendsCApplicationComponent
classErrorHandlerextendsApplicationComponent
{
{
/**
/**
* @var integer maximum number of source code lines to be displayed. Defaults to 25.
* @var integer maximum number of source code lines to be displayed. Defaults to 25.
*/
*/
public$maxSourceLines=25;
public$maxSourceLines=25;
/**
/**
* @var integer maximum number of trace source code lines to be displayed. Defaults to 10.
* @var integer maximum number of trace source code lines to be displayed. Defaults to 10.
* @since 1.1.6
*/
*/
public$maxTraceSourceLines=10;
public$maxTraceSourceLines=10;
/**
/**
* @var string the application administrator information (could be a name or email link). It is displayed in error pages to end users. Defaults to 'the webmaster'.
* @var string the application administrator information (could be a name or email link). It is displayed in error pages to end users. Defaults to 'the webmaster'.
*/
*/
public$adminInfo='the webmaster';
public$adminInfo='the webmaster';
/**
/**
* @var boolean whether to discard any existing page output before error display. Defaults to true.
* @var boolean whether to discard any existing page output before error display. Defaults to true.
*/
*/
public$discardOutput=true;
public$discardExistingOutput=true;
/**
/**
* @var string the route (eg 'site/error') to the controller action that will be used to display external errors.
* @var string the route (eg 'site/error') to the controller action that will be used to display external errors.
* Inside the action, it can retrieve the error information by Yii::app()->errorHandler->error.
* Inside the action, it can retrieve the error information by Yii::app()->errorHandler->error.
* This property defaults to null, meaning CErrorHandler will handle the error display.
* This property defaults to null, meaning ErrorHandler will handle the error display.
*/
*/
public$errorAction;
public$errorAction;
private$_error;
private$_error;
public$exception;
public$compactOutput;
/**
publicfunctioninit()
* Handles the exception/error event.
* This method is invoked by the application whenever it captures
* an exception or PHP error.
* @param CEvent $event the event containing the exception/error information
*/
publicfunctionhandle($event)
{
{
// set event as handled to prevent it from being handled by other event handlers