Skip to content

Commit 2378141

Browse files
committed
Handle ConnectException's too
1 parent cec30dc commit 2378141

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
### Fixed
1616
- Fixed an error that could occur when calling `craft\webhooks\Plugin::getRequestData()` if an invalid request ID was passed.
1717
- Fixed an exception that could occur when retrying webhook requests, if the queue driver didn’t support delayed jobs.
18+
- Fixed an exception that could occur when sending webhook requests, if Guzzle wasn’t able to connect to the server.
1819

1920
## 2.3.3 - 2021-04-01
2021

src/Plugin.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use DateTime;
2626
use GuzzleHttp\Exception\GuzzleException;
2727
use GuzzleHttp\Exception\RequestException;
28+
use GuzzleHttp\Exception\TransferException;
2829
use GuzzleHttp\RequestOptions;
2930
use ReflectionClass;
3031
use Throwable;
@@ -391,13 +392,16 @@ public function sendRequest(int $requestId): bool
391392
->execute();
392393

393394
$startTime = microtime(true);
395+
$response = null;
394396
try {
395397
$response = Craft::createGuzzleClient($this->getSettings()->guzzleConfig)
396398
->request($data['method'], $data['url'], $options);
397399
$success = true;
398-
} catch (RequestException $e) {
399-
$response = $e->getResponse();
400+
} catch (TransferException $e) {
400401
$success = false;
402+
if ($e instanceof RequestException) {
403+
$response = $e->getResponse();
404+
}
401405
}
402406

403407
// Update the request

0 commit comments

Comments
 (0)