phpyiiyii-events

Yii actionError not handling request when error occurs


I have made my custom controller and set it as default in my main config file.

All the other actions are working fine. But when there is any error i have made :

 public function actionError() {
      echo 'Error'; die;
  } 

and then i made a not found request. It did not did the action written by me, but did default action.

Please suggest!!


Solution

  • If you want to use your custom error action, you have to configure the errorAction in the errorHandler application component. You can do so in your main.php. If your controller is CustomController you'd configure:

    'components' => array(
        // ...
        'errorHandler' => array(
            'errorAction' => 'custom/error',
        ),
        // ...