valk
valk

Reputation: 9874

Zend catches all exceptions before me?

I'm having trouble with catching Zend exceptions. It looks like Zend has it's own exception handling which doesn't re-throw the exceptions. Then as a result I get the white screen with the exception description. Is there any way to catch it and display nicely?

$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
}

The error is:

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')

...

Upvotes: 3

Views: 1655

Answers (1)

Niko
Niko

Reputation: 26730

Solution (see comments on question for explanation):

try {
    $restClientResult = $client->get();
} catch (Zend_Exception $e) {
    doSomething();
}

Upvotes: 3

Related Questions