Try-Catch all Exceptions with Zend_Http_Client?
I have the following function:
public function getClientTable($feedUrl)
{
    $client = new Zend_Http_Client($feedUrl);
    try
    {
        return $client->request()->getBody();
    }
    catch (Zend_Http_Client_Adapter_Exception $e)
    {
        return false;
    }
}
It seems to work great for catching th开发者_运维技巧at specific Zend_Http_Client_Adapter_Exception; but what if I want it to catch additional exceptions? Hell, what if I wanted it to catch ALL exceptions... how would I do this?
Also, should I be using "return" or "throw" in the try? Why does it matter?
You can have multiple catch statements, eg
try { 
    // whatever
} catch (Zend_Http_Client_Adapter_Exception $e) {
    // ah ha
} catch (Zend_Some_other_Exception $e) {
    // ah ha
} catch (Exception $e) {
    // And the final fallback catch that grabs all exceptions
}
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论