background preloader

Yii Error Handling

Facebook Twitter

Error Handling. Yii provides a complete error handling framework based on the PHP 5 exception mechanism.

Error Handling

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.

Exceptions. Extending Exceptions PHP 5 has an exception model similar to that of other programming languages.

Exceptions

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.