문제

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!!

도움이 되었습니까?

해결책

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',
    ),
    // ...

다른 팁

You dont have to echo inside the controller.Create a view file inside your views folder and render it like so public function actionError(){ $this->render('viewName') }

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top