Commit c3cc7479 authored by Yas Naoi's avatar Yas Naoi
Browse files

Issue #3295254 by yas: Refactor the error message: "Cannot load cloud service...

Issue #3295254 by yas: Refactor the error message: "Cannot load cloud service provider plugin: (CloudConfig::$cloud_context)"
parent 04ef1617
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -4667,9 +4667,9 @@ function aws_cloud_get_instance_types($cloud_context, $refresh = TRUE): array {
    else {
      // Cannot load cloud service provider (CloudConfig) entity.
      // Show an error to the user.

      $message = t('Cannot load cloud service provider plugin: %cloud_context ($cloud_context) at aws_cloud_get_instance_types()', [
      $message = t('Cannot load cloud service provider plugin: %cloud_context ($cloud_context) at %method', [
        '%cloud_context' => !empty($cloud_context) ? $cloud_context : '<Empty>',
        '%method' => __METHOD__ . '()',
      ]);
      \Drupal::messenger()->addError($message);
      \Drupal::logger('cloud')->error($message);
+6 −4
Original line number Diff line number Diff line
@@ -114,8 +114,9 @@ class CloudProviderLink extends MenuLinkDefault {
        $title = $config->getName();
      }
      catch (\Exception $e) {
        $message = $this->t('Cannot load cloud service provider plugin: %cloud_context ($cloud_context) at Drupal\cloud\Plugin\Menu\CloudProviderLink::getTitle()', [
          '%cloud_context' => !empty($cloud_context) ? $cloud_context : '<Empty>',
        $message = $this->t('Cannot load cloud service provider plugin: %cloud_context ($cloud_context) at %method', [
          '%cloud_context' => $cloud_context,
          '%method' => __METHOD__ . '()',
        ]);
        $this->messenger->addError($message);
        $this->logger('cloud')->error($message);
@@ -136,8 +137,9 @@ class CloudProviderLink extends MenuLinkDefault {
        $route = $this->cloudConfigPluginManager->getInstanceCollectionTemplateName();
      }
      catch (\Exception $e) {
        $message = $this->t('Cannot load cloud service provider plugin: %cloud_context ($cloud_context) at Drupal\cloud\Plugin\Menu\getRouteName()', [
          '%cloud_context' => !empty($cloud_context) ? $cloud_context : '<Empty>',
        $message = $this->t('Cannot load cloud service provider plugin: %cloud_context ($cloud_context) at %method', [
          '%cloud_context' => $cloud_context,
          '%method' => __METHOD__ . '()',
        ]);
        $this->messenger->addError($message);
        $this->logger('cloud')->error($message);
+10 −8
Original line number Diff line number Diff line
@@ -122,8 +122,9 @@ class CloudConfigPluginManager extends CloudPluginManager implements CloudConfig
    if (empty($this->plugin)) {
      // DO NOT translate the message.
      // @see https://www.drupal.org/docs/develop/coding-standards/php-exceptions
      $message = $this->t('Cannot load cloud service provider plugin: %cloud_context ($cloud_context) at Drupal\cloud\Plugin\cloud\config\CloudConfigPluginManager::setCloudContext()', [
      $message = $this->t('Cannot load cloud service provider plugin: %cloud_context ($cloud_context) at %method', [
        '%cloud_context' => !empty($cloud_context) ? $cloud_context : '<Empty>',
        '%method' => __METHOD__ . '()',
      ]);
      $this->logger('cloud')->error($message);
      throw new CloudConfigPluginException($message);
@@ -159,8 +160,9 @@ class CloudConfigPluginManager extends CloudPluginManager implements CloudConfig
      ? $this->plugin->loadConfigEntity($this->cloudContext) : NULL;

    if (empty($config_entity)) {
      $message = $this->t('Cannot load cloud service provider plugin: %cloud_context (CloudConfig::$cloud_context) at ', [
      $message = $this->t('Cannot load cloud service provider plugin: %cloud_context ($cloud_context) at %method', [
        '%cloud_context' => !empty($this->cloud_context) ? $this->cloud_context : '<Empty>',
        '%method' => __METHOD__ . '()',
      ]);
      $this->logger('cloud')->error($message);
      throw new CloudConfigPluginException($message);
@@ -177,12 +179,12 @@ class CloudConfigPluginManager extends CloudPluginManager implements CloudConfig
    /** @var \Drupal\cloud\Plugin\cloud\config\CloudConfigPluginInterface $plugin */
    $plugin = $this->loadBasePluginDefinition($entity_bundle);
    if (empty($plugin)) {
      // NOTE: According to Drupal coding standards,
      // exceptions should not be translated.
      throw new CloudConfigPluginException(sprintf(
        'Cannot load cloud service provider (CloudConfig) entity for %s',
        $entity_bundle
      ));
      $message = $this->t('Cannot load cloud service provider entity (CloudConfig) for %bundle at %method', [
        '%bundle' => !empty($entity_bundle) ? $entity_bundle : '<Empty>',
        '%method' => __METHOD__ . '()',
      ]);
      $this->logger('cloud')->error($message);
      throw new CloudConfigPluginException($message);
    }
    return $plugin->loadConfigEntities();
  }