Newer versions of Guzzle will throw a BadResponseException if there is an issue with the server response. They also now throw a ConnectException if there are troubles connecting (timeout, curl, etc).
If you are targeting PHP 7.1+, you could use a union catch catch (BadResponseException | ConnectException $e) but if the target is just PHP 7, then you can use the TransferException as both BadResponseException and ConnectException extend it.
Newer versions of Guzzle will throw a
BadResponseException
if there is an issue with the server response. They also now throw aConnectException
if there are troubles connecting (timeout, curl, etc).If you are targeting PHP 7.1+, you could use a union catch
catch (BadResponseException | ConnectException $e)
but if the target is just PHP 7, then you can use theTransferException
as bothBadResponseException
andConnectException
extend it.