I don't really understand how to catch an exception (forward it) within the onReject handler. I was wondering if anyone can point me in the right direction on how to successfully do so.
I'm sending in some async requests and when one fails with "An uncaught Exception was encountered - Type: GuzzleHttp\Exception\ClientException" it never gets caught.
I have read:
But it's not clear why the following doesn't work. My understanding is when the ClientException is thrown within the onReject (RequestException) it will then push it further down to the next onReject (ClientException) and be caught properly.
Any help would be appreciated.
$client = new GuzzleHttp\Client();
$promise = $client->requestAsync('POST', SOME_URL, [
... SOME_PARAMS ...
]);
$promise->then(
function (ResponseInterface $res) {
//ok
},
function (RequestException $e) {
//inside here throws a ClientException
}
)->then(null, function (ClientException $e) {
//Why does it not get caught/forwarded to this error handler?
});