From 6d98068d3e334c1b00bbeb011f94c39370c475e0 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sat, 11 Jun 2022 13:25:36 +1200 Subject: [PATCH] Catch & convert Guzzle exception --- CRM/Extension/Browser.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CRM/Extension/Browser.php b/CRM/Extension/Browser.php index 42fe8fa574..4fe82f18e5 100644 --- a/CRM/Extension/Browser.php +++ b/CRM/Extension/Browser.php @@ -9,6 +9,8 @@ +--------------------------------------------------------------------+ */ +use GuzzleHttp\Exception\GuzzleException; + /** * This class glues together the various parts of the extension * system. @@ -250,7 +252,15 @@ class CRM_Extension_Browser { $url = $this->getRepositoryUrl() . $this->indexPath; $client = $this->getGuzzleClient(); - $response = $client->request('GET', $url, ['sink' => $filename, 'timeout' => \Civi::settings()->get('http_timeout')]); + try { + $response = $client->request('GET', $url, [ + 'sink' => $filename, + 'timeout' => \Civi::settings()->get('http_timeout'), + ]); + } + catch (GuzzleException $e) { + throw new CRM_Extension_Exception(ts('The CiviCRM public extensions directory at %1 could not be contacted - please check your webserver can make external HTTP requests', [1 => $this->getRepositoryUrl()]), 'connection_error'); + } restore_error_handler(); if ($response->getStatusCode() !== 200) { -- 2.25.1