我在捕获 Zend 异常时遇到了问题。看起来 Zend 有它自己的异常处理,不会重新抛出异常。结果我得到了带有异常描述的白屏。有什么方法可以捕捉并很好地显示吗?
$client = new Zend_Rest_Client($url);
// Get instance of Zend_Http_Client
$httpClient = $client->getHttpClient();
// Change the timeout
$httpClient->setConfig(array(
"timeout" => 0.1 // This is just for test
));
try {
$restClientResult = $client->get();
} catch (Zend_Rest_Client_Result_Exception $e) {
doSomething(); // <- is not entered here
}
错误是:
An error occurred
Exception information:
Message: Unable to Connect to ssl://localhost/resource:443. Error #110: Connection timed out
Stack trace:
#0 /.../lib/Zend/Http/Client.php(974): Zend_Http_Client_Adapter_Socket->connect('localhost/resour...', 443, true)
#1 /.../lib/Zend/Rest/Client.php(137): Zend_Http_Client->request('GET')
...
最佳答案
解决方案(解释见问题评论):
try {
$restClientResult = $client->get();
} catch (Zend_Exception $e) {
doSomething();
}
关于php - Zend 在我之前捕获所有异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9906476/