commit 6b0461416b1bf7197d135390e2de00f7717bf2af
Author: Franck Deroche <defr@ows.fr>
Date:   Thu Sep 14 11:35:08 2017 +0200

    Bug #2908754 by DeFr: Handle missing files gracefully

diff --git a/modules/entity_share_client/src/Service/JsonapiHelper.php b/modules/entity_share_client/src/Service/JsonapiHelper.php
index 28f2885..4902f29 100644
--- a/modules/entity_share_client/src/Service/JsonapiHelper.php
+++ b/modules/entity_share_client/src/Service/JsonapiHelper.php
@@ -17,6 +17,7 @@ use Drupal\entity_share_client\Event\RelationshipFieldValueEvent;
 use Drupal\file\FileInterface;
 use Drupal\jsonapi\Normalizer\JsonApiDocumentTopLevelNormalizer;
 use Drupal\jsonapi\ResourceType\ResourceTypeRepository;
+use GuzzleHttp\Exception\ClientException;
 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
 use Symfony\Component\Serializer\SerializerInterface;
 
@@ -266,10 +267,15 @@ class JsonapiHelper implements JsonapiHelperInterface {
         $remote_uri_real_path = $stream_wrapper->realpath();
         // TODO: Check the case of large files.
         // TODO: Transfer file only if necessary.
-        $file_content = $this->getFileHttpClient()->get($data['attributes']['url'])
-          ->getBody()
-          ->getContents();
-        file_put_contents($remote_uri_real_path, $file_content);
+        try {
+          $file_content = $this->getFileHttpClient()->get($data['attributes']['url'])
+            ->getBody()
+            ->getContents();
+          file_put_contents($remote_uri_real_path, $file_content);
+        }
+        catch (ClientException $e) {
+          drupal_set_message($this->t('Missing file: %url', ['%url' => $data['attributes']['url']]), 'warning');
+        }
       }
       else {
         drupal_set_message($this->t('Impossible to write in the directory %directory', ['%directory' => $directory_uri]), 'error');
