I currently have the problem that I need customized views for CExceptions. While I know how to do this with CHttpException (creating views called errorXXX) I don’t know how to achieve this with a class extending CException. The reason is that I am working on an extension (ActiveResource for Yii) that throws custom Exceptions that display sensitive information to the developer, NOT to the end user (imagine a REST service error response with some data about uris and error bodies…I think that shouldn’t be seen by users)
I know I could change the system view “exception” in the framework folder but that isn’t a very elegant way as this view is perfectly fine for classic exceptions
I see, but still a bit clumsy compared to the CHttpExceptions. I think I’ll better log the error response and only display that an error occured so nobody has to change any system files in order to use my extension
But you don’t have to change a system file for it (at least if by system file you mean a framework file). It’s a change in the default SiteController.php.
I’d suggest rolling a custom Exception that you can use to do your handling in the SiteController as Mike suggested. Perhaps you can catch it in other ways in the config, I’m not sure to be honest. i.e.
Also a valid option. I think, then you should configure your custom errorHandler component (extending CErrorHandler) and override handleException(). Inside that you then can take special care of your custom exception type.