为什么这个抛出的异常会重复出现?
这是这个问题的后续问题,并不是很重要。
我编写了以下前端控制器插件:
public function postDispatch(Zend_Controller_Request_Abstract $request)
{
$response = $this->getResponse();
$monitor = Zend_Registry::get('monitor');
if ($response->isException())
{
$monitor->log($response);
}
}
其中 $monitor 是自定义数据库日志记录类(扩展 Zend_Log)的实例。
在 Monitor 的 log 方法中,我循环遍历 $response->getException() 返回的 Zend_Exceptions 数组。
出于测试目的,我通过操作中的异常:
throw new Zend_Exception('the big test', 555);
大多数事情按预期工作,异常被写入数据库。
问题
但是,它写了两次。为什么?
This is a follow up question of this question, which is not really important.
I have written the following front controller plugin:
public function postDispatch(Zend_Controller_Request_Abstract $request)
{
$response = $this->getResponse();
$monitor = Zend_Registry::get('monitor');
if ($response->isException())
{
$monitor->log($response);
}
}
Where $monitor is an instance of a custom DB logging class (extending Zend_Log).
In the log method of the Monitor I loop over the Array of Zend_Exceptions returned by $response->getException().
For testing purposes I through an exception in an action:
throw new Zend_Exception('the big test', 555);
Most things work as expected, the Exception is written to the database.
Question
But, it's written twice. Why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为调度循环被调用了两次。首先针对当前操作,然后针对 default:error:error :) 将日志放入
dispatchLoopShutdown()
方法Because the dispatch loop is called twice. First for the current action and then for default:error:error :) Place the log into
dispatchLoopShutdown()
method