Answer the question
In order to leave comments, you need to log in
How to catch Exception in php5.6 (guzzle5.3)?
I use guzzle to send requests.
Often I get responses with 403 or 404 codes.
I have it written like this
try {
...
} catch (\GuzzleHttp\Exception\RequestException $e) {
...
}
Exception 'GuzzleHttp\Exception\ConnectException' with message 'cURL error 35: Unknown SSL protocol error in connection to ... '
in .../vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:49
Answer the question
In order to leave comments, you need to log in
absolutely nothing. interception of several exceptions appeared 7.1
crookedly possible like this
catch( Exception $e )
{
if ($e instanceof \GuzzleHttp\Exception\RequestException OR $e instanceof GuzzleHttp\Exception\ConnectException) {
} else {
throw $e;
}
https://github.com/guzzle/guzzle/blob/5.3/src/Exce...
ConnectException extends RequestException
catch (\GuzzleHttp\Exception\RequestException $e) will catch both exceptions. Check code and stacktrace. Perhaps you are looking at the wrong catch.
And what's the problem with catching all exceptions like this:
try {
...
} catch (\Exception $e) {
...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question