From 9832fa6c45007e76334755ed79e8f34e28edd920 Mon Sep 17 00:00:00 2001 From: Matthew Exon Date: Sun, 28 May 2023 11:02:32 +0200 Subject: [PATCH] catch exception during http request --- mailstream/mailstream.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mailstream/mailstream.php b/mailstream/mailstream.php index f53d4fe9..56e7fa13 100644 --- a/mailstream/mailstream.php +++ b/mailstream/mailstream.php @@ -214,7 +214,12 @@ function mailstream_do_images(array &$item, array &$attachments) } $cookiejar = tempnam(System::getTempPath(), 'cookiejar-mailstream-'); - $curlResult = DI::httpClient()->fetchFull($url, HttpClientAccept::DEFAULT, 0, $cookiejar); + try { + $curlResult = DI::httpClient()->fetchFull($url, HttpClientAccept::DEFAULT, 0, $cookiejar); + } catch (InvalidArgumentException $e) { + Logger::error('mailstream_do_images exception fetching url', ['url' => $url, 'item_id' => $item['id']]); + continue; + } $attachments[$url] = [ 'data' => $curlResult->getBody(), 'guid' => hash('crc32', $url), -- 2.39.5