Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • BaseDocsMassAction
  • CApplication
  • CApplicationComponent
  • CBehavior
  • CComponent
  • CEnumerable
  • CErrorEvent
  • CErrorHandler
  • CEvent
  • CExceptionEvent
  • CModel
  • CModelBehavior
  • CModelEvent
  • CModule
  • CommonFieldsBehavior
  • CSecurityManager
  • CStatePersister
  • Expression
  • MassAction
  • MassAddToList
  • MassCompleteAction
  • MassMoveFileSysObjToFolder
  • MassRemoveFromList
  • MassRenameFileSysObj
  • MassUncompleteAction
  • MobileRecentItems
  • ModulePanelItem
  • NewListFromSelection
  • PanelItem
  • QuickCRUDBehavior
  • RecentItemPanelItem
  • ServiceRoutingBehavior
  • SettingsPanelItem
  • X2AddressBehavior
  • X2AuthCache
  • X2BaseListViewBehavior

Interfaces

  • IAction
  • IApplicationComponent
  • IAuthManager
  • IBehavior
  • IFilter
  • IStatePersister
  • IUserIdentity
  • IViewRenderer
  • IWebServiceProvider
  • IWebUser

Exceptions

  • CException
  • CHttpException
  • TwitterFeedWidgetException
  • Overview
  • Package
  • Class
  • Tree

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;
where <StatusCode> stands for the HTTP error code (e.g. error500.php). Localized views are named similarly but located under a subdirectory whose name is the language code (e.g. zh_cn/error500.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:
  1. themes/ThemeName/views/<span class="php-keyword2">system</span>: when a theme is active.
  2. <span class="php-keyword1">protected</span>/views/<span class="php-keyword2">system</span>
  3. framework/views
If the view is not found in a directory, it will be looked for in the next directory.

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
Extended by CApplicationComponent implements IApplicationComponent
Extended by CErrorHandler
Package: system\base
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
Methods summary
public
# handle( CEvent $event )

Handles the exception/error event. This method is invoked by the application whenever it captures an exception or PHP error.

Handles the exception/error event. This method is invoked by the application whenever it captures an exception or PHP error.

Parameters

$event
CEvent
$event the event containing the exception/error information
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:
  • code - the HTTP status code (e.g. 403, 500)
  • type - the error type (e.g. 'CHttpException', 'PHP Error')
  • message - the error message
  • file - the name of the PHP script file where the error occurs
  • line - the line number of the code where the error occurs
  • trace - the call stack of the error
  • source - the context source code where the error occurs
Returns the details about the error that is currently being handled. The error is returned in terms of an array, with the following information:
  • code - the HTTP status code (e.g. 403, 500)
  • type - the error type (e.g. 'CHttpException', 'PHP Error')
  • message - the error message
  • file - the name of the PHP script file where the error occurs
  • line - the line number of the code where the error occurs
  • trace - the call stack of the error
  • source - the context source code where the error occurs

Returns

array
the error details. Null if there is no error.
public Exception|null
# getException( )

Returns the instance of the exception that is currently being handled.

Returns the instance of the exception that is currently being handled.

Returns

Exception|null
exception instance. Null if there is no exception.
protected
# handleException( Exception $exception )

Handles the exception.

Handles the exception.

Parameters

$exception
Exception
$exception the exception captured
protected
# handleError( CErrorEvent $event )

Handles the PHP error.

Handles the PHP error.

Parameters

$event
CErrorEvent
$event the PHP error event
protected boolean
# isAjaxRequest( )

whether the current request is an AJAX (XMLHttpRequest) request.

whether the current request is an AJAX (XMLHttpRequest) request.

Returns

boolean
whether the current request is an AJAX request.
protected array
# getExactTrace( Exception $exception )

Returns the exact trace where the problem occurs.

Returns the exact trace where the problem occurs.

Parameters

$exception
Exception
$exception the uncaught exception

Returns

array
the exact trace where the problem occurs
protected
# render( string $view, array $data )

Renders the view.

Renders the view.

Parameters

$view
string
$view the view name (file name without extension). See CErrorHandler::getViewFile() for how a view file is located given its name.
$data
array
$data data to be passed to the view
protected
# renderException( )

Renders the exception information. This method will display information from current error value.

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.

Renders the current error information. This method will display information from current error value.

protected string
# getViewFile( string $view, integer $code )

Determines which view file should be used.

Determines which view file should be used.

Parameters

$view
string
$view view name (either 'exception' or 'error')
$code
integer
$code HTTP status code

Returns

string
view file path
protected string
# getViewFileInternal( string $viewPath, string $view, integer $code, string $srcLanguage = null )

Looks for the view under the specified directory.

Looks for the view under the specified directory.

Parameters

$viewPath
string
$viewPath the directory containing the views
$view
string
$view view name (either 'exception' or 'error')
$code
integer
$code HTTP status code
$srcLanguage
string
$srcLanguage the language that the view file is in

Returns

string
view file path
protected string
# getVersionInfo( )

Returns server version information. If the application is in production mode, empty string is returned.

Returns server version information. If the application is in production mode, empty string is returned.

Returns

string
server version information. Empty if in production mode.
protected string
# argumentsToString( array $args )

Converts arguments array to its string representation

Converts arguments array to its string representation

Parameters

$args
array
$args arguments array to be converted

Returns

string
string representation of the arguments array
protected boolean
# isCoreCode( array $trace )

Returns a value indicating whether the call stack is from application code.

Returns a value indicating whether the call stack is from application code.

Parameters

$trace
array
$trace the trace data

Returns

boolean
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.

Renders the source code around the error line.

Parameters

$file
string
$file source file path
$errorLine
integer
$errorLine the error line number
$maxLines
integer
$maxLines maximum number of lines to display

Returns

string
the rendering result
protected string
# getHttpHeader( integer $httpCode, string $replacement = '' )

Return correct message for each known http error code

Return correct message for each known http error code

Parameters

$httpCode
integer
$httpCode error code to map
$replacement
string
$replacement replacement error string that is returned if code is unknown

Returns

string
the textual representation of the given error code or the replacement string if the error code is unknown
Methods inherited from CApplicationComponent
getIsInitialized(), init()
Methods inherited from CComponent
__call(), __get(), __isset(), __set(), __unset(), asa(), attachBehavior(), attachBehaviors(), attachEventHandler(), canGetProperty(), canSetProperty(), detachBehavior(), detachBehaviors(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), getEventHandlers(), hasEvent(), hasEventHandler(), hasProperty(), raiseEvent()
Properties summary
public integer $maxSourceLines 25
#

maximum number of source code lines to be displayed. Defaults to 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.

maximum number of trace source code lines to be displayed. Defaults to 10.

Since

1.1.6
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'.

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.

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.

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.

Properties inherited from CApplicationComponent
$behaviors
Magic properties summary
public array $error
#

The error details. Null if there is no error.

The error details. Null if there is no error.

public Exception|null $exception
#

exception instance. Null if there is no exception.

exception instance. Null if there is no exception.

Magic properties inherited from CApplicationComponent
$isInitialized
API documentation generated by ApiGen 2.8.0