From ee5dbd6c8af720f97cf6864874266a7f637f452b Mon Sep 17 00:00:00 2001 From: Cameron Ball Date: Fri, 27 Oct 2023 13:21:31 +0800 Subject: [PATCH] Don't eat GuzzleExceptions when requests fail Eating the exception prevents errors from surfacing in logs. Additionally the (now removed) implementation of guzzle_exception did not fully implement a PSR-7 response. --- classes/esrequest.php | 3 -- classes/guzzle_exception.php | 61 ------------------------------------ 2 files changed, 64 deletions(-) delete mode 100644 classes/guzzle_exception.php diff --git a/classes/esrequest.php b/classes/esrequest.php index 28b6138..900a3ec 100644 --- a/classes/esrequest.php +++ b/classes/esrequest.php @@ -120,9 +120,6 @@ private function http_action($psr7request) { $response = $this->client->send($psr7request); } catch (\GuzzleHttp\Exception\BadResponseException $e) { $response = $e->getResponse(); - } catch (\GuzzleHttp\Exception\GuzzleException $e) { - // This case does not provide a response object with a consistent interface so we need to make one. - $response = new \search_elastic\guzzle_exception(); } return $response; diff --git a/classes/guzzle_exception.php b/classes/guzzle_exception.php deleted file mode 100644 index 2fb52f3..0000000 --- a/classes/guzzle_exception.php +++ /dev/null @@ -1,61 +0,0 @@ -. - -/** - * Custom Guzzle exception class. - * - * Guzzle returns a standard response object for regular (successful) responses - * as well as for errors raised by \GuzzleHttp\Exception\BadResponseException. - * However it does not raise a standard response object for \GuzzleHttp\Exception\GuzzleException. - * - * This class provides a simple interface response object interface for errors raised with - * \GuzzleHttp\Exception\GuzzleException. - * - * @package search_elastic - * @copyright Matt Porritt - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -namespace search_elastic; - -/** - * Custom Guzzle exception class. - * - * Guzzle returns a standard response object for regular (successful) responses - * as well as for errors raised by \GuzzleHttp\Exception\BadResponseException. - * However it does not raise a standard response object for \GuzzleHttp\Exception\GuzzleException. - * - * This class provides a simple interface response object interface for errors raised with - * \GuzzleHttp\Exception\GuzzleException. - * - * @package search_elastic - * @copyright Matt Porritt - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class guzzle_exception { - - // @codingStandardsIgnoreStart - /** - * Return error code for a URL that does not resolve. - * - * @return int The return code for a failure. - */ - public function getStatusCode() { - return 410; - } - // @codingStandardsIgnoreEnd - -}