From c9585fa82a74cc54ca229754bbe6764c74e634e4 Mon Sep 17 00:00:00 2001 From: Fran Garcia-Linares <14157-fjgarlin@users.noreply.drupalcode.org> Date: Mon, 27 Jan 2025 15:13:16 +0000 Subject: [PATCH] Issue #3502465 by fjgarlin, phenaproxima, tim.plunkett: Reduce the amount of information relayed on error by the DrupalOrgJsonApi plugin to the front-end --- .../DrupalDotOrgJsonApi.php | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/Plugin/ProjectBrowserSource/DrupalDotOrgJsonApi.php b/src/Plugin/ProjectBrowserSource/DrupalDotOrgJsonApi.php index 84b22cd6f..6a2ef5f16 100644 --- a/src/Plugin/ProjectBrowserSource/DrupalDotOrgJsonApi.php +++ b/src/Plugin/ProjectBrowserSource/DrupalDotOrgJsonApi.php @@ -16,7 +16,6 @@ use Drupal\project_browser\ProjectBrowser\Project; use Drupal\project_browser\ProjectBrowser\ProjectsResultsPage; use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\GuzzleException; -use GuzzleHttp\Exception\RequestException; use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Response; @@ -172,20 +171,13 @@ final class DrupalDotOrgJsonApi extends ProjectBrowserSourceBase { } } } - catch (RequestException $exception) { - $this->logger->error($exception->getMessage()); - $result['message'] = $exception->getMessage(); - $result['code'] = $exception->getCode(); - } - catch (GuzzleException $exception) { - $this->logger->error($exception->getMessage()); - $result['message'] = $exception->getMessage(); - $result['code'] = $exception->getCode(); - } catch (\Throwable $exception) { $this->logger->error($exception->getMessage()); - $result['message'] = $exception->getMessage(); - $result['code'] = Response::HTTP_INTERNAL_SERVER_ERROR; + $result['message'] = $this->t('An error occurred while fetching data from drupal.org. See the error log for details, or <a href="@report_issue">report the issue</a>. While this error persists, you can browse the <a href="@drupalorg_catalog">project catalog on drupal.org</a>.', [ + '@report_issue' => 'https://www.drupal.org/node/add/project-issue/drupalorg', + '@drupalorg_catalog' => 'https://www.drupal.org/project/project_module', + ]); + $result['code'] = $exception->getCode(); } return $result; -- GitLab