2
Zendの例外を捕まえることに問題があります。 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')
...
が見えます。これがどんな型の例外であるかを判断するには、 'catch(Exception $ e){var_dump(get_class($ e));'を試してください。 – Niko
それを考え出した。 私はZend_Rest_Client_Result_Exceptionを捕まえていました。 これをZend_Exceptionに変更しました。これで問題ありません。 @ニコ、ありがとう、我々は同じ結論に来た:)私は解決策としてマークすることができますので、質問に答えてください。 – valk