From 2d3080fe709bae1a90e323e609f655e395aa159e Mon Sep 17 00:00:00 2001 From: Tschallacka <mdibbets@outlook.com> Date: Thu, 20 Apr 2023 12:59:22 +0200 Subject: [PATCH] Throw an exception instead of an empty list return https://github.com/dpdconnect/php-sdk/blob/master/src/Common/ResourceClient.php#L87 uses list($status, $response). When an error is returned from dpd api, the entire shipping backend crashes, as an array index of 0 does not exist on an empty array. By transforming the exception to a DpdException it gets caught by https://github.com/dpdconnect/php-sdk/blob/12cabc0e204c56e5e9a7ff1fdde4492810cce6a2/src/Resources/Product.php#L34 and gets handled properly by returning a cached instance. And the magento2 shipping configuration page works. --- src/Common/AuthenticatedHttpClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Common/AuthenticatedHttpClient.php b/src/Common/AuthenticatedHttpClient.php index 0caf2f5..163b48d 100644 --- a/src/Common/AuthenticatedHttpClient.php +++ b/src/Common/AuthenticatedHttpClient.php @@ -87,7 +87,7 @@ public function sendRequest($httpMethod, $resourceName, array $query = [], array ); $response = $this->basicHttpClient->sendRequest($httpMethod, $resourceName, $query, $headers, $body); } catch (AuthenticateException $exception) { - $response = []; + throw new DpdException('Error response from DPD. '.$exception->getMessage(), $exception->getCode(), $exception); } }