Yii Error Handling
Error Handling. Yii provides a complete error handling framework based on the PHP 5 exception mechanism.
When the application is created to handle an incoming user request, it registers its handleError method to handle PHP warnings and notices; and it registers its handleException method to handle uncaught PHP exceptions. Consequently, if a PHP warning/notice or an uncaught exception occurs during the application execution, one of the error handlers will take over the control and start the necessary error handling procedure. Tip: The registration of error handlers is done in the application's constructor by calling PHP functions set_exception_handler and set_error_handler. If you do not want Yii to handle the errors and exceptions, you may define constant YII_ENABLE_ERROR_HANDLER and YII_ENABLE_EXCEPTION_HANDLER to be false in the entry script. By default, handleError (or handleException) will raise an onError event (or onException event). CException. Catching ALL db-related exception.
, on 01 February 2011 - 01:11 PM, said: You can do everything within the handler, i.e. accessing Yii::app() without problems. The idea, you provided, seems to be great! :] I do have PHP 5.3.1 but even so I'm using the older method of attaching onException event handler. Exceptions. Extending Exceptions PHP 5 has an exception model similar to that of other programming languages.
An exception can be thrown, and caught ("catched") within PHP. Code may be surrounded in a try block, to facilitate the catching of potential exceptions. Exception. When you are using xdebug, exceptions message will never be shown if you use any encoding different than UTF-8, so if you are using any database with translated messages like oracle, you should ALWAYS, always, throw a exception like this throw new Exception(utf8_encode($message),$code), character like ã,é,ç, will make the exception message fail to be shown, if you are not using xdebug ( I do think you should at least try), this code will not affect your page.