From a8442e41abf4a4badb6dc7d09c24910e7194e37b Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 6 Aug 2021 04:02:42 +0000 Subject: [PATCH] Improved error message for external resources --- src/Module/Photo.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Module/Photo.php b/src/Module/Photo.php index e669de8a3d..06a369df77 100644 --- a/src/Module/Photo.php +++ b/src/Module/Photo.php @@ -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