Chapter: Error manager
|^ Development helper tools||Creating unit tests »|
− Table of content
The classes of the framework can generate errors in two different ways with :
- a trigger_error (PHP error)
- an exception
A PHP error is generated in the case of a technical error due to a programing default. It is then the job of the developer to correct the error.
An exception is generated in the case of an error that can occur in an unpredictable way during the execution of an action. For example, an error when it is impossible to connect to a database or a "functional", "business" error.
Error handlers setup ¶
Whatever the error comes from, we get it through an error handler (except for the exceptions which are interpreted by a try/catch block). There is an error handler for PHP errors and another for the exceptions.
The error handlers are in charge of executing the actions specified in the configuration according to the error type. This is the default", "error", "warning", "notice", "strict", "exception" parameters in the error_hanling section. Each of these parameters has to contain one or several of these words which indicates an action to be executed :
|ECHO||The message will be passed in the response|
|LOGFILE||The message is put in the log file specified in the ligfile option of the configuration|
|SYSLOG||The message is sent in the system log|
|The message is sent by mail to the address specified in the mail option|
|EXIT||The execution stops here (EXIT is implicit for the exceptions)|
|TRACE||Include the call stack in the log file|
|ECHOQUIET||Does not display the details of the message, only displays the content of the quietMessage option from the error_handling section|
messageLogFormat specifies an error message format used when printing errors to log file, syslog file or mail. this format supports some special keywords
If you want to show errors in Firebug (when ECHO is used, and only for HTML and XUL responses), set showInFirebug to on.
Error code ¶
Each error message is localized in the properties files and each error should have a number. This number is indicated in the properties files of the localized messages, this way :
key.string = (error_code)error message
In the end, the error message won't be with the error code. And this one will be extracted
Here are the error codes fields
|> 5000||user errors|
If you generate errors for your own use, their code must be greater than 5000.