From da0d55bcd05f2ca6c9847af7db69be71641f4f0c Mon Sep 17 00:00:00 2001 From: Harry Lewis Date: Mon, 19 Aug 2024 17:24:52 +0100 Subject: [PATCH] Update website.com exception handler to return a formatted error response for connection exceptions --- src/Providers/Websitecom/Provider.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Providers/Websitecom/Provider.php b/src/Providers/Websitecom/Provider.php index dd4c7fc..e4b105d 100644 --- a/src/Providers/Websitecom/Provider.php +++ b/src/Providers/Websitecom/Provider.php @@ -7,6 +7,7 @@ use GuzzleHttp\Client; use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\TransferException; use GuzzleHttp\RequestOptions; use Illuminate\Support\Str; use Throwable; @@ -162,6 +163,14 @@ protected function handleException(\Throwable $e, $params = null): void } } + if ($e instanceof TransferException) { + throw $this->errorResult('Provider API Connection Failed', [ + 'exception' => get_class($e), + 'code' => $e->getCode(), + 'message' => $e->getMessage(), + ], [], $e); + } + throw $e; }