开发者

Zend framework- how to stop execution and redirect to the error controller

I want to catch php errors so i used set_error_handler('handler_function') when i echo the error message , 'Zend_Controller_Response_Exception' with message 'Cannot send headers; headers already sent' is thrown when i used the following lines

$fc=Zend_Controller_Front::getInstance();
$fc->getResponse()->setBody($error);

an error happened 'call to setBody method of a non-object'

i tried to throw an exception from the error handler but this depend on the error occurring before bootstrapping is displayed directly after bootstrapping displayed in errorController i used $fc->throwExc开发者_如何学Goeptions(false) to ensure it will send exceptions to error controller

when i do nothing in the error handler the execution is continued

what i need is to have one place to handle all errors

if there is a way to redirect to the error controller with error in params this will be good


IMO best way to handle these errors is to register error handler that will convert any error/fatal error to exception. I guess that response is not created yet. You have to use $fc's setResponse() method to create new response. I would guess that converting to exception should work in any case. Same as exceptions from Zend classes work.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜