开发者

Zend Framework Error handling

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 开发者_StackOverflowexisting 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);


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


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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜