Skip to content
Snippets Groups Projects
Commit 29ed5059 authored by Fran Garcia-Linares's avatar Fran Garcia-Linares Committed by Tim Plunkett
Browse files

Issue #3502604 by fjgarlin, chrisfromredfin, drumm: Differentiate type of...

Issue #3502604 by fjgarlin, chrisfromredfin, drumm: Differentiate type of errors received from DrupalOrg source
parent 8cb9687c
No related branches found
No related tags found
1 merge request!693Different message for 4xx errors.
Checking pipeline status
......@@ -172,12 +172,23 @@ final class DrupalDotOrgJsonApi extends ProjectBrowserSourceBase {
}
}
catch (\Throwable $exception) {
$this->logger->error($exception->getMessage());
$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 <a href="@drupalorg_catalog">browse modules on Drupal.org</a>.', [
$error_code = (int) $exception->getCode();
$this->logger->error('Error code: @error_code.<br>Message: @error_message.<br>You can report the issue <a href="@report_issue">in the Drupal.org issue queue</a>.', [
'@error_code' => $error_code,
'@error_message' => $exception->getMessage(),
'@report_issue' => 'https://www.drupal.org/node/add/project-issue/drupalorg',
]);
$reason = $this->t('An error occurred while fetching data from Drupal.org.');
if ($error_code >= 400 && $error_code < 500) {
$reason = ($error_code === 403) ?
$this->t('The request made to Drupal.org is likely invalid or might have been blocked. Ensure you are running the latest version of Project Browser') :
$this->t('The request made to Drupal.org is likely invalid. Ensure you are running the latest version of Project Browser');
}
$result['message'] = $this->t('@reason. See the error log for details. While this error persists, you can <a href="@drupalorg_catalog">browse modules on Drupal.org</a>.', [
'@reason' => $reason,
'@drupalorg_catalog' => 'https://www.drupal.org/project/project_module',
]);
$result['code'] = $exception->getCode();
$result['code'] = $error_code;
}
return $result;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment