I've created a Custom error handler class (CMyErrorHandler) that extends from CErrorHandler.
However when I configure the class of the errorHandler component in config/main.php to be CMyErrorHandler, Yii still seems to be using the old CErrorHandler class.
'errorHandler'=>array(
'errorAction'=>'site/error',
'class' => 'application.components.CMyErrorHandler',
),
How can I manage to use my Custom error handler? Thanks!
Did you already verified if your CMyErrorHandler
is extending CErrorHandler
correctly?
Maybe this link can help you: view_findpost_ p _155043">http://www.yiiframework.com/forum/index.php/topic/32160-custom-error-logging/page_ view _findpost_ p _155043
I found the source of my problem. I's not possible to extend CErrorHandler and just override the two methods I needed (handleError and handleException), because these methods use a private variable un CErrorHandle which is not accessible in the extended class CMyErrorHandle. I believe this is due to a bad design in Yii's CErrorHandle class (though I must say I absolutely love the framework). Therefore I opted to copy paste the whole class and make the changes I needed in both methods. After these everything worked as expected.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.