Skip to content
Snippets Groups Projects

Issue #3186977: Show third party message on oEmbed resource exception

Open Scott Euser requested to merge issue/drupal-3186977:9.5.x into 9.5.x
2 files
+ 15
2
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -71,7 +71,20 @@ public function fetchResource($url) {
]);
}
catch (TransferException $e) {
throw new ResourceException('Could not retrieve the oEmbed resource.', $url, [], $e);
$exception_message = 'Could not retrieve the oEmbed resource.';
$response = $e->getResponse();
if ($response) {
$body = $response->getBody();
$contents = json_decode($body->getContents(), TRUE);
if ($contents && is_array($contents['error']) && isset($contents['error']['message'])) {
$exception_message = $contents['error']['message'];
}
}
elseif ($response_message = $e->getMessage()) {
$exception_message = $response_message;
}
throw new ResourceException($exception_message, $url, [], $e);
}
[$format] = $response->getHeader('Content-Type');
Loading