diff --git a/core/modules/media/src/Controller/OEmbedIframeController.php b/core/modules/media/src/Controller/OEmbedIframeController.php index 9da8f90502..e024b47bbc 100644 --- a/core/modules/media/src/Controller/OEmbedIframeController.php +++ b/core/modules/media/src/Controller/OEmbedIframeController.php @@ -212,9 +212,17 @@ public function render(Request $request) { // The oEmbed system makes heavy use of exception wrapping, so log the // entire exception chain to help with troubleshooting. do { - // @todo Log additional information from ResourceException, to help with - // debugging, in https://www.drupal.org/project/drupal/issues/2972846. - $this->logger->error($e->getMessage()); + $message = $e->getMessage(); + $context = []; + if ($e->getUrl()) { + $message .= ' URL: {url}.'; + $context['url'] = $e->getUrl(); + } + if ($e->getData()) { + $message .= ' Data:
{data}
'; + $context['data'] = var_export($e->getData(), TRUE); + } + $this->logger->error($message, $context); $e = $e->getPrevious(); } while ($e); } diff --git a/core/modules/media/src/OEmbed/ProviderRepository.php b/core/modules/media/src/OEmbed/ProviderRepository.php index b62d0ccac2..cadaf09fd1 100644 --- a/core/modules/media/src/OEmbed/ProviderRepository.php +++ b/core/modules/media/src/OEmbed/ProviderRepository.php @@ -135,6 +135,7 @@ public function getAll() { catch (ProviderException $e) { // Skip invalid providers, but log the exception message to help with // debugging. + // https://www.drupal.org/project/drupal/issues/2972846 $this->logger->warning($e->getMessage()); } } diff --git a/core/modules/media/src/OEmbed/ResourceFetcher.php b/core/modules/media/src/OEmbed/ResourceFetcher.php index 62b39499fe..e19c07436c 100644 --- a/core/modules/media/src/OEmbed/ResourceFetcher.php +++ b/core/modules/media/src/OEmbed/ResourceFetcher.php @@ -67,7 +67,7 @@ public function fetchResource($url) { ]); } catch (TransferException $e) { - throw new ResourceException('Could not retrieve the oEmbed resource.', $url, [], $e); + throw new ResourceException('Could not retrieve the oEmbed resource: ' . $e->getMessage(), $url, [], $e); } [$format] = $response->getHeader('Content-Type'); diff --git a/core/modules/media/src/Plugin/Validation/Constraint/OEmbedResourceConstraintValidator.php b/core/modules/media/src/Plugin/Validation/Constraint/OEmbedResourceConstraintValidator.php index e39b2055cc..5bec132d34 100644 --- a/core/modules/media/src/Plugin/Validation/Constraint/OEmbedResourceConstraintValidator.php +++ b/core/modules/media/src/Plugin/Validation/Constraint/OEmbedResourceConstraintValidator.php @@ -137,10 +137,17 @@ protected function handleException(\Exception $e, $error_message = NULL) { // The oEmbed system makes heavy use of exception wrapping, so log the // entire exception chain to help with troubleshooting. do { - // @todo If $e is a ProviderException or ResourceException, log additional - // debugging information contained in those exceptions in - // https://www.drupal.org/project/drupal/issues/2972846. - $this->logger->error($e->getMessage()); + $message = $e->getMessage(); + $context = []; + if ($e->getUrl()) { + $message .= ' URL: {url}.'; + $context['url'] = $e->getUrl(); + } + if ($e->getData()) { + $message .= ' Data:
{data}
'; + $context['data'] = var_export($e->getData(), TRUE); + } + $this->logger->error($message, $context); $e = $e->getPrevious(); } while ($e); } diff --git a/core/modules/media/src/Plugin/media/Source/OEmbed.php b/core/modules/media/src/Plugin/media/Source/OEmbed.php index 14f677acf0..adbed8b133 100644 --- a/core/modules/media/src/Plugin/media/Source/OEmbed.php +++ b/core/modules/media/src/Plugin/media/Source/OEmbed.php @@ -442,7 +442,8 @@ protected function getLocalThumbnailUri(Resource $resource) { } } catch (TransferException $e) { - $this->logger->warning('Failed to download remote thumbnail file due to "%error".', [ + $this->logger->warning('Failed to download remote thumbnail from {url} due to "%error".', [ + 'url' => $remote_thumbnail_url, '%error' => $e->getMessage(), ]); } diff --git a/core/modules/media_library/tests/src/FunctionalJavascript/WidgetOEmbedTest.php b/core/modules/media_library/tests/src/FunctionalJavascript/WidgetOEmbedTest.php index 5a79363198..8534387d32 100644 --- a/core/modules/media_library/tests/src/FunctionalJavascript/WidgetOEmbedTest.php +++ b/core/modules/media_library/tests/src/FunctionalJavascript/WidgetOEmbedTest.php @@ -314,7 +314,7 @@ public function testWidgetOEmbedAdvancedUi() { // assertWaitOnAjaxRequest() required for input "id" attributes to // consistently match their label's "for" attribute. $assert_session->assertWaitOnAjaxRequest(); - $this->waitForText('Could not retrieve the oEmbed resource.'); + $this->waitForText('Could not retrieve the oEmbed resource:'); // Select a media item to check if the selection is persisted when adding // new items.