Class CErrorHandler
CErrorHandler handles uncaught PHP errors and exceptions.
It displays these errors using appropriate views based on the nature of the error and the mode the application runs at. It also chooses the most preferred language for displaying the error.
CErrorHandler uses two sets of views:- development views, named as
exception.php
; - production views, named as
error<StatusCode>.php
;
Development views are displayed when the application is in debug mode (i.e. YII_DEBUG is defined as true). Detailed error information with source code are displayed in these views. Production views are meant to be shown to end-users and are used when the application is in production mode. For security reasons, they only display the error message without any sensitive information.
CErrorHandler looks for the view templates from the following locations in order:themes/ThemeName/views/<span class="php-keyword2">system</span>
: when a theme is active.<span class="php-keyword1">protected</span>/views/<span class="php-keyword2">system</span>
framework/views
The property CErrorHandler::$maxSourceLines
can be changed to specify the number of
source code lines to be displayed in development views.
CErrorHandler is a core application component that can be accessed via CApplication::getErrorHandler()
.
- CComponent
- CApplicationComponent implements IApplicationComponent
- CErrorHandler
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.0
Located at x2engine/framework/base/CErrorHandler.php
public
|
|
public
array
|
#
getError( )
Returns the details about the error that is currently being handled. The error
is returned in terms of an array, with the following information:
|
public
|
|
protected
|
|
protected
|
|
protected
boolean
|
|
protected
array
|
|
protected
|
|
protected
|
#
renderException( )
Renders the exception information. This method will display information from current error value. |
protected
|
#
renderError( )
Renders the current error information. This method will display information from current error value. |
protected
string
|
|
protected
string
|
#
getViewFileInternal( string $viewPath, string $view, integer $code, string $srcLanguage = null )
Looks for the view under the specified directory. |
protected
string
|
#
getVersionInfo( )
Returns server version information. If the application is in production mode, empty string is returned. |
protected
string
|
|
protected
boolean
|
#
isCoreCode( array $trace )
Returns a value indicating whether the call stack is from application code. |
protected
string
|
#
renderSourceCode( string $file, integer $errorLine, integer $maxLines )
Renders the source code around the error line. |
protected
string
|
#
getHttpHeader( integer $httpCode, string $replacement = '' )
Return correct message for each known http error code |
getIsInitialized(),
init()
|
public
integer
|
$maxSourceLines | 25 |
#
maximum number of source code lines to be displayed. Defaults to 25. |
public
integer
|
$maxTraceSourceLines | 10 |
#
maximum number of trace source code lines to be displayed. Defaults to 10. |
public
string
|
$adminInfo | 'the webmaster' |
#
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
boolean
|
$discardOutput | true |
#
whether to discard any existing page output before error display. Defaults to true. |
public
string
|
$errorAction |
|
#
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. This property defaults to null, meaning CErrorHandler will handle the error display. |
$behaviors
|
public
array
|
$error |
#
The error details. Null if there is no error. |
public
|
$exception |
#
exception instance. Null if there is no exception. |
$isInitialized
|