ChttpException not being displayed

Hi all,

I am throwing an CHttpException from a controller, and expected the correct page to be shown. By following the guide I have in the main configuration:




          'errorHandler'=>array(

			// use 'site/error' action to display errors

            'errorAction'=>'site/error',

        ),



In the log I have the following:




2011/08/02 20:52:46 [error] [exception.CHttpException.404] exception 'CHttpException' with message 'You are trying to activate with bad information!' in /home/ole/workspace/project/project/protected/controllers/UserController.php:179

Stack trace:

#0 /home/ole/workspace/project/project/framework/web/actions/CInlineAction.php(50): UserController->actionVerify()

#1 /home/ole/workspace/project/project/framework/web/CController.php(300): CInlineAction->runWithParams(Array)

#2 /home/ole/workspace/project/project/framework/web/filters/CFilterChain.php(133): CController->runAction(Object(CInlineAction))

#3 /home/ole/workspace/project/project/framework/web/filters/CFilter.php(41): CFilterChain->run()

#4 /home/ole/workspace/project/project/framework/web/CController.php(1122): CFilter->filter(Object(CFilterChain))

#5 /home/ole/workspace/project/project/framework/web/filters/CInlineFilter.php(59): CController->filterAccessControl(Object(CFilterChain))

#6 /home/ole/workspace/project/project/framework/web/filters/CFilterChain.php(130): CInlineFilter->filter(Object(CFilterChain))

#7 /home/ole/workspace/project/project/framework/web/CController.php(283): CFilterChain->run()

#8 /home/ole/workspace/project/project/framework/web/CController.php(257): CController->runActionWithFilters(Object(CInlineAction), Array)

#9 /home/ole/workspace/project/project/framework/web/CWebApplication.php(328): CController->run('verify')

#10 /home/ole/workspace/project/project/framework/web/CWebApplication.php(121): CWebApplication->runController('user/verify')

#11 /home/ole/workspace/project/project/framework/base/CApplication.php(155): CWebApplication->processRequest()

#12 /home/ole/workspace/project/project/index.php(13): CApplication->run()

#13 {main} REQUEST_URI=/project/index.php/user/verify

2011/08/02 20:52:46 [trace] [system.CModule] Loading "errorHandler" application component



So from what this I see that the correct error is thrown. Have I not set up the error handler correctly?

Btw, I do not get anything shown when I try to call an action that does not exist either.

Anyone got a clue?

Thanks

If you use Gii-generated code you should have actionError() in SiteController.php and the view file error.php in protected/views/site (you also may want to add error.php in e.g protected/views/site/no).

/Tommy

Hi Tommy,

and thanks for the reply! Yup, the code is Gii generated, and what you are mentioning is in place, and the error.php is set to be rendered.

I see in the log that also the errorHandler is loaded:




2011/08/03 19:09:04 [trace] [system.CModule] Loading "errorHandler" application component



And debugging a bit more I find that the function in SiteController is called, but when printing:




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



It just says Array, which i guess means it is empty (sorry for my lack of php skills.). Does this mean the Exception is not caught correctly?

The error was a bug in the Gii code in the actionError() function. The else block was wrong.

Did you find any solution ?