[ Index ]
 

Code source de PRADO 3.0.6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/framework/Exceptions/ -> TErrorHandler.php (sommaire)

TErrorHandler class file

Author: Qiang Xue <qiang.xue@gmail.com>
Copyright: Copyright © 2005 PradoSoft
License: http://www.pradosoft.com/license/
Version: $Id: TErrorHandler.php 1397 2006-09-07 07:55:53Z wei $
Poids: 259 lignes (10 kb)
Inclus ou requis: 1 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 1 class

TErrorHandler:: (7 méthodes):
  init()
  getErrorTemplatePath()
  setErrorTemplatePath()
  handleError()
  handleExternalError()
  handleRecursiveError()
  displayException()


Classe: TErrorHandler  - X-Ref

TErrorHandler class

TErrorHandler handles all PHP user errors and exceptions generated during
servicing user requests. It displays these errors using different templates
and if possible, using languages preferred by the client user.
Note, PHP parsing errors cannot be caught and handled by TErrorHandler.

The templates used to format the error output are stored under System.Exceptions.
You may choose to use your own templates, should you not like the templates
provided by Prado. Simply set {@link setErrorTemplatePath ErrorTemplatePath}
to the path (in namespace format) storing your own templates.

There are two sets of templates, one for errors to be displayed to client users
(called external errors), one for errors to be displayed to system developers
(called internal errors). The template file name for the former is
<b>error[StatusCode][-LanguageCode].html</b>, and for the latter it is
<b>exception[-LanguageCode].html</b>, where StatusCode refers to response status
code (e.g. 404, 500) specified when {@link THttpException} is thrown,
and LanguageCode is the client user preferred language code (e.g. en, zh, de).
The templates <b>error.html</b> and <b>exception.html</b> are default ones
that are used if no other appropriate templates are available.
Note, these templates are not Prado control templates. They are simply
html files with keywords (e.g. %%ErrorMessage%%, %%Version%%)
to be replaced with the corresponding information.

By default, TErrorHandler is registered with {@link TApplication} as the
error handler module. It can be accessed via {@link TApplication::getErrorHandler()}.
You seldom need to deal with the error handler directly. It is mainly used
by the application object to handle errors.

TErrorHandler may be configured in application configuration file as follows
<module id="error" class="TErrorHandler" ErrorTemplatePath="System.Exceptions" />

init($config)   X-Ref
Initializes the module.
This method is required by IModule and is invoked by application.

param: TXmlElement module configuration

getErrorTemplatePath()   X-Ref

return: string the directory containing error template files.

setErrorTemplatePath($value)   X-Ref
Sets the path storing all error and exception template files.
The path must be in namespace format, such as System.Exceptions (which is the default).

param: string template path in namespace format

handleError($sender,$param)   X-Ref
Handles PHP user errors and exceptions.
This is the event handler responding to the <b>Error</b> event
raised in {@link TApplication}.
The method mainly uses appropriate template to display the error/exception.
It terminates the application immediately after the error is displayed.

param: mixed sender of the event
param: mixed event parameter (if the event is raised by TApplication, it refers to the exception instance)

handleExternalError($statusCode,$exception)   X-Ref
Displays error to the client user.
THttpException and errors happened when the application is in <b>Debug</b>
mode will be displayed to the client user.

param: integer response status code
param: Exception exception instance

handleRecursiveError($exception)   X-Ref
Handles error occurs during error handling (called recursive error).
THttpException and errors happened when the application is in <b>Debug</b>
mode will be displayed to the client user.
Error is displayed without using existing template to prevent further errors.

param: Exception exception instance

displayException($exception)   X-Ref
Displays exception information.
Exceptions are displayed with rich context information, including
the call stack and the context source code.
This method is only invoked when application is in <b>Debug</b> mode.

param: Exception exception instance



Généré le : Sun Feb 25 21:07:04 2007 par Balluche grâce à PHPXref 0.7