views:

118

answers:

2

Hi

I would like to use the default ErrorCongtroller to handle error. I registered it as a front controller plugin and it does nothing. Should I set something else to catch not existing controllers and actions or should I add some code to other controllers? Here's the code snippet for registration:

$front = Zend_Controller_Front::getInstance();
$front->registerPlugin(new Zend_Controller_Plugin_ErrorHandler());
$front->returnResponse(true);
$front->throwExceptions(true);
A: 

What happens when you set $front->throwExceptions( false );?

I believe the ErrorHandler only catches the Exceptions if you tell the front controller not to throw them (or, bubble them up, is what I mean I guess).

Also, are you doing anything with the returned response? Since you have set $front->returnResponse( true );, you need to collect the response yourself and output it with:

$response = $front->dispatch();
$response->sendResponse();
fireeyedboy
I already tried with both throwException true/false. There's no difference.
Hubidubi
A: 

What version of ZF are you using? As far as I noticed in the latest versions, the error handler is registered by default. Only "thing" that it needs is an ErrorController in the default module with an errorAction

See the manual for details: http://framework.zend.com/manual/en/zend.controller.plugins.html#zend.controller.plugins.standard.errorhandler

robertbasic
I use 1.9.5. I read that error controlle should be registered by default but it doesn't work. I use error controller from the Quickstart project (http://framework.zend.com/docs/quickstart/create-your-project)
Hubidubi