php - Zend 在我之前捕获所有异常?

标签 php http zend-framework exception try-catch

我在捕获 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/

相关文章:

zend-framework - Zend框架1.11 : how to autoload a class that uses namespaces

php - 图像在页面上加载多少次?

http - Apache Camel 作为 HTTP 代理 : how route to URL with parameters

http - 支持搜索时,Post Redirect Get 模式并在基于 RESTful 资源的服务中使用

apache - 使用 PHP5/Apache2 的 Http 请求持续时间

php - zend paginator 最终是否使用 LIMIT OFFSET

php - Zend_JSON :Encode messing up - why?

php - 客户端仅选择时的 SQL 注入(inject)

php - 在服务器端(PHP)还是客户端(Javascript)检测移动浏览器更好/更快?

php - 无法加载 Eloquent 模型的关系