How To Detect Which Action Generates An Error

I have made my custom errorHandler in this way


class MYController extends Controller{

      public function init(){

		parent::init();

                Yii::app()->errorHandler->errorAction='my/error';

      }

      public function actionError()

      {

		if($error=Yii::app()->errorHandler->error){

			if(Yii::app()->request->isAjaxRequest)

				echo $error['message'];

			else

				$this->redirect(array('content/create'));

		}

	}

}

However, I don’t know how to specify the reaction base on the trigger action, like I want to redirect the user to a new page when the error is triggered by actionCreate and code is 400 and display an error page when the error is is triggered by actionView

You can try this:




if($error=Yii::app()->errorHandler->error) {

    $actionName = $error['traces'][0]['function']; // with "action" prefix

    $controllerName = $error['traces'][0]['class'];

}