]> git.mxchange.org Git - friendica.git/commitdiff
Improved error message for external resources
authorMichael <heluecht@pirati.ca>
Fri, 6 Aug 2021 04:02:42 +0000 (04:02 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 6 Aug 2021 04:02:42 +0000 (04:02 +0000)
src/Module/Photo.php

index e669de8a3dcc04dd5059db288a2460e5d9a4b306..06a369df77d5e67bd81e9d8218eeb239c8641e56 100644 (file)
@@ -118,8 +118,14 @@ class Photo extends BaseModule
                $data = microtime(true) - $stamp;
 
                if (empty($imgdata)) {
-                       Logger::warning("Invalid photo with id {$photo["id"]}.");
-                       throw new \Friendica\Network\HTTPException\InternalServerErrorException(DI::l10n()->t('Invalid photo with id %s.', $photo["id"]));
+                       Logger::warning('Invalid photo', ['id' => $photo['id']]);
+                       if (in_array($photo['backend-class'], [ExternalResource::NAME])) {
+                               $reference = json_decode($photo['backend-ref'], true);
+                               $error = DI::l10n()->t('Invalid external resource with url %s.', $reference['url']);
+                       } else {
+                               $error = DI::l10n()->t('Invalid photo with id %s.', $photo['id']);
+                       }
+                       throw new \Friendica\Network\HTTPException\InternalServerErrorException($error);
                }
 
                // if customsize is set and image is not a gif, resize it