Php 为什么这个抛出的异常会重复?
这是一个关于的后续问题,其实并不重要 我已经编写了以下前端控制器插件:Php 为什么这个抛出的异常会重复?,php,zend-framework,exception-handling,zend-controller-plugin,Php,Zend Framework,Exception Handling,Zend Controller Plugin,这是一个关于的后续问题,其实并不重要 我已经编写了以下前端控制器插件: public function postDispatch(Zend_Controller_Request_Abstract $request) { $response = $this->getResponse(); $monitor = Zend_Registry::get('monitor'); if ($response->isException()) {
public function postDispatch(Zend_Controller_Request_Abstract $request)
{
$response = $this->getResponse();
$monitor = Zend_Registry::get('monitor');
if ($response->isException())
{
$monitor->log($response);
}
}
其中$monitor是自定义DB日志类(扩展Zend_日志)的实例
在Monitor的log方法中,我在$response->getException()返回的Zend_异常数组上循环
出于测试目的,我通过操作中的异常:
throw new Zend_Exception('the big test', 555);
大多数事情都按预期工作,异常会写入数据库
问题:
但是,它写了两次。为什么?因为调度循环被调用了两次。首先针对当前操作,然后针对默认操作:错误:错误:)将日志放入
dispatchLoopShutdown()
方法