From 9aa452e16dbd56d3d6db47b8a42d3d498f7628b5 Mon Sep 17 00:00:00 2001 From: Michael Babker Date: Thu, 14 Jan 2021 02:13:43 -0600 Subject: [PATCH] Change type of exception handled in rejected promise (#208) As noted in Guzzle's [upgrade document](https://github.com/guzzle/guzzle/blob/master/UPGRADING.md), in Guzzle 7 `GuzzleHttp\Exception\ConnectException` now extends from `GuzzleHttp\Exception\TransferException` instead of `GuzzleHttp\Exception\RequestException`, which now causes a fatal error in the rejected callback because ConnectException is no longer an instance of RequestException. This change allows for ConnectException to be handled when using Guzzle 7 while remaining B/C with Guzzle 6. --- src/MonitorCollection.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MonitorCollection.php b/src/MonitorCollection.php index 5036d0d6..8623fad5 100644 --- a/src/MonitorCollection.php +++ b/src/MonitorCollection.php @@ -4,7 +4,7 @@ use Generator; use GrahamCampbell\GuzzleFactory\GuzzleFactory; -use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\TransferException; use GuzzleHttp\Promise\EachPromise; use Illuminate\Support\Collection; use Psr\Http\Message\ResponseInterface; @@ -27,7 +27,7 @@ public function checkUptime(): void $monitor->uptimeRequestSucceeded($response); }, - 'rejected' => function (RequestException $exception, $index) { + 'rejected' => function (TransferException $exception, $index) { $monitor = $this->getMonitorAtIndex($index); ConsoleOutput::error("Could not reach {$monitor->url} error: `{$exception->getMessage()}`");