Handling exceptions in custom controller/action

Hi again,

Is there any way to change the user interface for the exceptions like errors shown in




Property "CWebApplication.appAuthManager" is not defined.

Source File


00081:     /**

00082:      * Getter magic method.

00083:      * This method is overridden to support accessing application components

00084:      * like reading module properties.

00085:      * @param string application component or property name

00086:      * @return mixed the named property value

00087:      */

I want to show this exception in my UI.

Thank you

I’m not sure what are you trying to do exactly… if you just want to show detailed error message in your error handler then you can use variables passed to it… from the definitive guide you linked:

I added the errorHandler component to my application but it is just handling php errors not exceptions like - CDbExceptions, CHttpExceptions etc. For exceptions I am getting regular Yii page showed above.

Here what I would like to do is if exception occurs, it should be displayed to the end user in my application user interface not all stack trace with sensitive information. Also I want to customize how the exception should be displayed to the end user.

I hope you will understand me!

Thank you!

sorry, I do not actually know how to do that, nover did try.

As I can see from the definitive guid to yii, you just provide your own error handler and there you can control the variables that will be outputed.

That said, I think you absolutely should give a stact trace and such thing, they are very helpufull when debugging and if you don’t your users wont be able to reprt a solid bug.

Check out the section on system views here:


Thanks for the replay mike!

Now I came to know I need to write a view for each exception errorcode under view/system directory!

Can u please tell me where do I get the list of exception error codes with some exception details.

Thank you!

Check the files in framework/views (exception.php and error*.php). These are all exception views used by Yii. Exceptions can be thrown from many different components. So there’s no full list of all possible exceptions.

Thanks for the reply mike,

  If I create exception.php in my system/views it will render that file instead of default Yii exception layout, thats good!  Here yii treats exception.php as a layout file and displays just this file contents. 

Is it possible to use this like action, so that I can use my application view layout and content of exception.php should be put into layout like other actions ( like in var $content in app layout).


You can provide your own ErrorHandler class. Check the source of framework/base/CErrorHandler.php for the default implementation. If you extend that class you can configure your custom handler as errorHandler application component.

Also read this: http://www.yiiframework.com/doc/guide/topics.error

I have configured errorHandler component and wrote errorAction, its working fine for just errors not for exceptions!

     If exception occurs, application is not calling the errorAction, it displays default yii exception layout.


I suggest to study the source code of CErrorHandler to find out, which methods you need to override. From it’s render() method you see, that errorAction is only used for non-exception errors.

Thanks for the reply Mike!

I will do that and let you know about it.

Hey Please Share the solution to your problem , i have the exact same problem. It wil be very greatful of you



I got the Solution

In index.php

Just comment the DEBUGGER AND STACK TRACE and all the exceptions will be handled exactly in the same layout your website is.