Improved error message for external resources

This commit is contained in:
Michael 2021-08-06 04:02:42 +00:00
parent 4bc3e8c141
commit a8442e41ab

View 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