Hello,
I’m currently trying to setup a custom actionError function for my api controllers. You can see my directory setup here.
Now I’ve created a ApiController.php in my Components folder with the following content:
class ApiController extends CController
{
public function init()
{
parent::init();
Yii::app()->errorHandler->errorAction = $this->actionError();
}
public function actionError()
{
if($error = Yii::app()->errorHandler->error)
echo CJSON::encode($error);
}
}
In my api controllers I inherit from this class, e.g.:
class UserController extends ApiController
When throwing an exception the actionError function doesn’t get executed.
Any idea how I can fix that problem?