From: Michael Date: Sun, 26 Feb 2023 22:43:45 +0000 (+0000) Subject: Use "Exception" X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6e3602591d52771f7f3c8c4c0d926a1690891730;p=friendica.git Use "Exception" --- diff --git a/src/Contact/Avatar.php b/src/Contact/Avatar.php index 4843e5d37c..299c263994 100644 --- a/src/Contact/Avatar.php +++ b/src/Contact/Avatar.php @@ -75,8 +75,8 @@ class Avatar try { $fetchResult = HTTPSignature::fetchRaw($avatar, 0, [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::IMAGE]]); - } catch (\Throwable $th) { - Logger::notice('Avatar is invalid', ['avatar' => $avatar, 'error' => $th]); + } catch (\Exception $exception) { + Logger::notice('Avatar is invalid', ['avatar' => $avatar, 'exception' => $exception]); return $fields; } diff --git a/src/Factory/Api/Mastodon/Notification.php b/src/Factory/Api/Mastodon/Notification.php index 52241e1fc8..e6e9f4d094 100644 --- a/src/Factory/Api/Mastodon/Notification.php +++ b/src/Factory/Api/Mastodon/Notification.php @@ -64,7 +64,7 @@ class Notification extends BaseFactory if ($Notification->targetUriId) { try { $status = $this->mstdnStatusFactory->createFromUriId($Notification->targetUriId, $Notification->uid, $display_quotes); - } catch (\Throwable $th) { + } catch (\Exception $exception) { $status = null; } } else { diff --git a/src/Factory/Api/Mastodon/Status.php b/src/Factory/Api/Mastodon/Status.php index 788841a9bc..f653107d40 100644 --- a/src/Factory/Api/Mastodon/Status.php +++ b/src/Factory/Api/Mastodon/Status.php @@ -266,8 +266,8 @@ class Status extends BaseFactory if ($is_reshare) { try { $reshare = $this->createFromUriId($uriId, $uid, $display_quote, false, false)->toArray(); - } catch (\Throwable $th) { - Logger::info('Reshare not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]); + } catch (\Exception $exception) { + Logger::info('Reshare not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]); $reshare = []; } } else { @@ -277,8 +277,8 @@ class Status extends BaseFactory if ($in_reply_status && ($item['gravity'] == Item::GRAVITY_COMMENT)) { try { $in_reply = $this->createFromUriId($item['thr-parent-id'], $uid, $display_quote, false, false)->toArray(); - } catch (\Throwable $th) { - Logger::info('Reply post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]); + } catch (\Exception $exception) { + Logger::info('Reply post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]); $in_reply = []; } } else { @@ -309,8 +309,8 @@ class Status extends BaseFactory if (!empty($quote_id)) { try { $quote = $this->createFromUriId($quote_id, $uid, false, false, false)->toArray(); - } catch (\Throwable $th) { - Logger::info('Quote not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]); + } catch (\Exception $exception) { + Logger::info('Quote not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]); $quote = []; } } else { diff --git a/src/Model/APContact.php b/src/Model/APContact.php index a429a7a5d4..20457b46e8 100644 --- a/src/Model/APContact.php +++ b/src/Model/APContact.php @@ -202,8 +202,8 @@ class APContact if (!$failed && ($curlResult->getReturnCode() == 410)) { $data = ['@context' => ActivityPub::CONTEXT, 'id' => $url, 'type' => 'Tombstone']; } - } catch (\Throwable $th) { - Logger::notice('Error fetching url', ['url' => $url, 'error' => $th]); + } catch (\Exception $exception) { + Logger::notice('Error fetching url', ['url' => $url, 'exception' => $exception]); $failed = true; } diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 64509b5d22..f35808f050 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -2228,8 +2228,8 @@ class Contact return; } } - } catch (\Throwable $th) { - Logger::notice('Error fetching avatar', ['avatar' => $avatar, 'error' => $th]); + } catch (\Exception $exception) { + Logger::notice('Error fetching avatar', ['avatar' => $avatar, 'exception' => $exception]); return; } } elseif (!empty($contact['blurhash'])) { diff --git a/src/Model/Post/Link.php b/src/Model/Post/Link.php index 4ac8173799..dc77979511 100644 --- a/src/Model/Post/Link.php +++ b/src/Model/Post/Link.php @@ -130,8 +130,8 @@ class Link if (empty($curlResult) || !$curlResult->isSuccess()) { return []; } - } catch (\Throwable $th) { - Logger::notice('Error fetching url', ['url' => $url, 'error' => $th]); + } catch (\Exception $exception) { + Logger::notice('Error fetching url', ['url' => $url, 'exception' => $exception]); return []; } $fields = ['mimetype' => $curlResult->getHeader('Content-Type')[0]]; diff --git a/src/Module/Api/Mastodon/Accounts/Statuses.php b/src/Module/Api/Mastodon/Accounts/Statuses.php index 067e330271..463411745c 100644 --- a/src/Module/Api/Mastodon/Accounts/Statuses.php +++ b/src/Module/Api/Mastodon/Accounts/Statuses.php @@ -120,8 +120,8 @@ class Statuses extends BaseApi self::setBoundaries($item['uri-id']); try { $statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes); - } catch (\Throwable $th) { - Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]); + } catch (\Exception $exception) { + Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]); } } DBA::close($items); diff --git a/src/Module/Api/Mastodon/Bookmarks.php b/src/Module/Api/Mastodon/Bookmarks.php index 615bfc501f..59cf7f54a2 100644 --- a/src/Module/Api/Mastodon/Bookmarks.php +++ b/src/Module/Api/Mastodon/Bookmarks.php @@ -77,8 +77,8 @@ class Bookmarks extends BaseApi self::setBoundaries($item['uri-id']); try { $statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes); - } catch (\Throwable $th) { - Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]); + } catch (\Exception $exception) { + Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]); } } DBA::close($items); diff --git a/src/Module/Api/Mastodon/Favourited.php b/src/Module/Api/Mastodon/Favourited.php index 93c9ef2436..7829f37d70 100644 --- a/src/Module/Api/Mastodon/Favourited.php +++ b/src/Module/Api/Mastodon/Favourited.php @@ -79,8 +79,8 @@ class Favourited extends BaseApi self::setBoundaries($item['thr-parent-id']); try { $statuses[] = DI::mstdnStatus()->createFromUriId($item['thr-parent-id'], $uid, $display_quotes); - } catch (\Throwable $th) { - Logger::info('Post not fetchable', ['uri-id' => $item['thr-parent-id'], 'uid' => $uid, 'error' => $th]); + } catch (\Exception $exception) { + Logger::info('Post not fetchable', ['uri-id' => $item['thr-parent-id'], 'uid' => $uid, 'exception' => $exception]); } } DBA::close($items); diff --git a/src/Module/Api/Mastodon/Lists/Accounts.php b/src/Module/Api/Mastodon/Lists/Accounts.php index 667cd87eab..e19dfb0314 100644 --- a/src/Module/Api/Mastodon/Lists/Accounts.php +++ b/src/Module/Api/Mastodon/Lists/Accounts.php @@ -117,7 +117,7 @@ class Accounts extends BaseApi self::setBoundaries($member['contact-id']); try { $accounts[] = DI::mstdnAccount()->createFromContactId($member['contact-id'], $uid); - } catch (\Throwable $th) { + } catch (\Exception $exception) { } } DBA::close($members); diff --git a/src/Module/Api/Mastodon/Search.php b/src/Module/Api/Mastodon/Search.php index c35e33062b..69e2627682 100644 --- a/src/Module/Api/Mastodon/Search.php +++ b/src/Module/Api/Mastodon/Search.php @@ -183,8 +183,8 @@ class Search extends BaseApi self::setBoundaries($item['uri-id']); try { $statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes); - } catch (\Throwable $th) { - Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]); + } catch (\Exception $exception) { + Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]); } } DBA::close($items); diff --git a/src/Module/Api/Mastodon/Timelines/Home.php b/src/Module/Api/Mastodon/Timelines/Home.php index 5efaf4930e..7fc179297c 100644 --- a/src/Module/Api/Mastodon/Timelines/Home.php +++ b/src/Module/Api/Mastodon/Timelines/Home.php @@ -99,8 +99,8 @@ class Home extends BaseApi self::setBoundaries($item['uri-id']); try { $statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes); - } catch (\Throwable $th) { - Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]); + } catch (\Exception $exception) { + Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]); } } DBA::close($items); diff --git a/src/Module/Api/Mastodon/Timelines/ListTimeline.php b/src/Module/Api/Mastodon/Timelines/ListTimeline.php index a8de13056e..1e9a5810c1 100644 --- a/src/Module/Api/Mastodon/Timelines/ListTimeline.php +++ b/src/Module/Api/Mastodon/Timelines/ListTimeline.php @@ -104,8 +104,8 @@ class ListTimeline extends BaseApi self::setBoundaries($item['uri-id']); try { $statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes); - } catch (\Throwable $th) { - Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]); + } catch (\Exception $exception) { + Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]); } } DBA::close($items); diff --git a/src/Module/Api/Mastodon/Timelines/PublicTimeline.php b/src/Module/Api/Mastodon/Timelines/PublicTimeline.php index 968e34dbb9..31750d4a5c 100644 --- a/src/Module/Api/Mastodon/Timelines/PublicTimeline.php +++ b/src/Module/Api/Mastodon/Timelines/PublicTimeline.php @@ -99,8 +99,8 @@ class PublicTimeline extends BaseApi self::setBoundaries($item['uri-id']); try { $statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes); - } catch (\Throwable $th) { - Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]); + } catch (\Exception $exception) { + Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]); } } DBA::close($items); diff --git a/src/Module/Api/Mastodon/Timelines/Tag.php b/src/Module/Api/Mastodon/Timelines/Tag.php index 64cd84366e..476c9c2b94 100644 --- a/src/Module/Api/Mastodon/Timelines/Tag.php +++ b/src/Module/Api/Mastodon/Timelines/Tag.php @@ -120,8 +120,8 @@ class Tag extends BaseApi self::setBoundaries($item['uri-id']); try { $statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes); - } catch (\Throwable $th) { - Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]); + } catch (\Exception $exception) { + Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]); } } DBA::close($items); diff --git a/src/Module/Api/Mastodon/Trends/Statuses.php b/src/Module/Api/Mastodon/Trends/Statuses.php index 884319aa48..336f671559 100644 --- a/src/Module/Api/Mastodon/Trends/Statuses.php +++ b/src/Module/Api/Mastodon/Trends/Statuses.php @@ -57,8 +57,8 @@ class Statuses extends BaseApi while ($status = Post::fetch($statuses)) { try { $trending[] = DI::mstdnStatus()->createFromUriId($status['uri-id'], $uid, $display_quotes); - } catch (\Throwable $th) { - Logger::info('Post not fetchable', ['uri-id' => $status['uri-id'], 'uid' => $uid, 'error' => $th]); + } catch (\Exception $exception) { + Logger::info('Post not fetchable', ['uri-id' => $status['uri-id'], 'uid' => $uid, 'exception' => $exception]); } } DBA::close($statuses); diff --git a/src/Module/Proxy.php b/src/Module/Proxy.php index 3f1e4b2b80..4d1e1c304b 100644 --- a/src/Module/Proxy.php +++ b/src/Module/Proxy.php @@ -92,8 +92,8 @@ class Proxy extends BaseModule self::responseError(); // stop. } - } catch (\Throwable $th) { - Logger::notice('Error fetching image', ['image' => $request['url'], 'error' => $th]); + } catch (\Exception $exception) { + Logger::notice('Error fetching image', ['image' => $request['url'], 'exception' => $exception]); self::responseError(); } diff --git a/src/Object/Image.php b/src/Object/Image.php index d6c897e88d..49196a0c44 100644 --- a/src/Object/Image.php +++ b/src/Object/Image.php @@ -718,7 +718,7 @@ class Image if ($image->isImagick()) { try { $colors = $image->image->getImagePixelColor($x, $y)->getColor(); - } catch (\Throwable $th) { + } catch (\Exception $exception) { return ''; } $row[] = [$colors['r'], $colors['g'], $colors['b']]; diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index 20736504ef..54acca9df3 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -572,8 +572,8 @@ class Processor { try { $curlResult = HTTPSignature::fetchRaw($url, 0); - } catch (\Throwable $th) { - Logger::notice('Error fetching url', ['url' => $url, 'error' => $th]); + } catch (\Exception $exception) { + Logger::notice('Error fetching url', ['url' => $url, 'exception' => $exception]); return true; } diff --git a/src/Util/HTTPSignature.php b/src/Util/HTTPSignature.php index fe623f2968..d48d02c20e 100644 --- a/src/Util/HTTPSignature.php +++ b/src/Util/HTTPSignature.php @@ -424,8 +424,8 @@ class HTTPSignature { try { $curlResult = self::fetchRaw($request, $uid); - } catch (\Throwable $th) { - Logger::notice('Error fetching url', ['url' => $request, 'error' => $th]); + } catch (\Exception $exception) { + Logger::notice('Error fetching url', ['url' => $request, 'exception' => $exception]); return []; }