Yii Error Handling

Facebook Twitter
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).
Y!!, 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. Catching ALL db-related exception Catching ALL db-related exception
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. Exceptions Exceptions