Whenever there is an issue like hitting the API rate limits or network timeout or any issue at all, an exception is thrown which is not caught anywhere. As a result node save just fails. This is frustrating as just a status message would suffice.

This is apparently very similar to #2989600: Exception thrown when saving an address that cannot be geolocated but the fix is very different. In the 8.x-3.x branch, we are correctly catching all kinds of exceptions, not just InvalidCredentials or PluginException. However, I don't know if that branch is safe to use as there is no release yet. I think this is a simple enough fix for 8.x-2.x.

CommentFileSizeAuthor
#2 3005330-2.patch783 byteshussainweb

Comments

hussainweb created an issue. See original summary.

hussainweb’s picture

Status: Active » Needs review
StatusFileSize
new783 bytes

Attaching a patch to log the exception properly. I know the code is exactly same as the other catch blocks but I assume they are there for a reason and so I added a new catch block to catch \Exception and didn't modify the existing catch (InvalidCredentials $e) block.

Ideally, I think the whole code block can just boil down to this:

      try {
        $provider = $this->providerPluginManager->createInstance($plugin_id, $plugins_options[$plugin_id]);
        return $provider->reverse($latitude, $longitude);
      }
      catch (\Exception $e) {
        static::log($e->getMessage());
      }

Even if the logging has to vary for different types of exceptions, that can be done above by just adding more catch blocks.

      try {
        $provider = $this->providerPluginManager->createInstance($plugin_id, $plugins_options[$plugin_id]);
        return $provider->reverse($latitude, $longitude);
      }
      catch (InvalidCredentials $e) {
        static::log($e->getMessage());
      }
      catch (PluginException $e) {
        static::log($e->getMessage());
      }
      catch (\Exception $e) {
        static::log($e->getMessage());
      }

If above is preferable, I am happy to modify the patch.

hussainweb’s picture

Status: Needs review » Closed (duplicate)