How To Use A Specific Error Handler In A Controller?

I’m serving REST API which need to return JSON format error messages along with normal functionality with Yii, I specified an error handler in config/main.php to make customized error page, but this applies globally.

Is there anyway I can use a specific error handler in api controller to throw JSON error message instead of default error page?

Yes, it’s possible: Check out this thread for more info: http://www.yiiframework.com/forum/index.php/topic/15484-custom-errorhandler-for-specific-controller/