The best way to handle 404, 403, etc...

Greetings!

Still learning the basics of Yii. And little confused with handling 'not found'/'forbidden' errors. The trouble is that for every type of error there is a need to define specific layout (errorXXX.php in views/system). So I got a question:

What is the best way to catch them out? Maybe by extending CErrorHandler or CHttpException?

Any help will be appreciated.

Darmen

If you have a file named error.php, it will catch all errors if the corresponding errorXXX.php is not defined.

Thanks, Qiang

But how can I call certain errorController?

There is only error handler which you can access via Yii::app()->errorHandler.

Ok, but if somebody wants to call his own controller when an error appears - what man should do?

Yii::app()->controller gives the controller currently requested.