Skip to content

Commit

Permalink
Change type of exception handled in rejected promise (#208)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mbabker authored Jan 14, 2021
1 parent f34ba95 commit 9aa452e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/MonitorCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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()}`");
Expand Down

0 comments on commit 9aa452e

Please sign in to comment.