Use "Exception"

This commit is contained in:
Michael 2023-02-26 22:43:45 +00:00
parent 2b513a48c7
commit 6e3602591d
20 changed files with 41 additions and 41 deletions

View File

@ -75,8 +75,8 @@ class Avatar
try { try {
$fetchResult = HTTPSignature::fetchRaw($avatar, 0, [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::IMAGE]]); $fetchResult = HTTPSignature::fetchRaw($avatar, 0, [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::IMAGE]]);
} catch (\Throwable $th) { } catch (\Exception $exception) {
Logger::notice('Avatar is invalid', ['avatar' => $avatar, 'error' => $th]); Logger::notice('Avatar is invalid', ['avatar' => $avatar, 'exception' => $exception]);
return $fields; return $fields;
} }

View File

@ -64,7 +64,7 @@ class Notification extends BaseFactory
if ($Notification->targetUriId) { if ($Notification->targetUriId) {
try { try {
$status = $this->mstdnStatusFactory->createFromUriId($Notification->targetUriId, $Notification->uid, $display_quotes); $status = $this->mstdnStatusFactory->createFromUriId($Notification->targetUriId, $Notification->uid, $display_quotes);
} catch (\Throwable $th) { } catch (\Exception $exception) {
$status = null; $status = null;
} }
} else { } else {

View File

@ -266,8 +266,8 @@ class Status extends BaseFactory
if ($is_reshare) { if ($is_reshare) {
try { try {
$reshare = $this->createFromUriId($uriId, $uid, $display_quote, false, false)->toArray(); $reshare = $this->createFromUriId($uriId, $uid, $display_quote, false, false)->toArray();
} catch (\Throwable $th) { } catch (\Exception $exception) {
Logger::info('Reshare not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]); Logger::info('Reshare not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]);
$reshare = []; $reshare = [];
} }
} else { } else {
@ -277,8 +277,8 @@ class Status extends BaseFactory
if ($in_reply_status && ($item['gravity'] == Item::GRAVITY_COMMENT)) { if ($in_reply_status && ($item['gravity'] == Item::GRAVITY_COMMENT)) {
try { try {
$in_reply = $this->createFromUriId($item['thr-parent-id'], $uid, $display_quote, false, false)->toArray(); $in_reply = $this->createFromUriId($item['thr-parent-id'], $uid, $display_quote, false, false)->toArray();
} catch (\Throwable $th) { } catch (\Exception $exception) {
Logger::info('Reply post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]); Logger::info('Reply post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]);
$in_reply = []; $in_reply = [];
} }
} else { } else {
@ -309,8 +309,8 @@ class Status extends BaseFactory
if (!empty($quote_id)) { if (!empty($quote_id)) {
try { try {
$quote = $this->createFromUriId($quote_id, $uid, false, false, false)->toArray(); $quote = $this->createFromUriId($quote_id, $uid, false, false, false)->toArray();
} catch (\Throwable $th) { } catch (\Exception $exception) {
Logger::info('Quote not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]); Logger::info('Quote not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]);
$quote = []; $quote = [];
} }
} else { } else {

View File

@ -202,8 +202,8 @@ class APContact
if (!$failed && ($curlResult->getReturnCode() == 410)) { if (!$failed && ($curlResult->getReturnCode() == 410)) {
$data = ['@context' => ActivityPub::CONTEXT, 'id' => $url, 'type' => 'Tombstone']; $data = ['@context' => ActivityPub::CONTEXT, 'id' => $url, 'type' => 'Tombstone'];
} }
} catch (\Throwable $th) { } catch (\Exception $exception) {
Logger::notice('Error fetching url', ['url' => $url, 'error' => $th]); Logger::notice('Error fetching url', ['url' => $url, 'exception' => $exception]);
$failed = true; $failed = true;
} }

View File

@ -2228,8 +2228,8 @@ class Contact
return; return;
} }
} }
} catch (\Throwable $th) { } catch (\Exception $exception) {
Logger::notice('Error fetching avatar', ['avatar' => $avatar, 'error' => $th]); Logger::notice('Error fetching avatar', ['avatar' => $avatar, 'exception' => $exception]);
return; return;
} }
} elseif (!empty($contact['blurhash'])) { } elseif (!empty($contact['blurhash'])) {

View File

@ -130,8 +130,8 @@ class Link
if (empty($curlResult) || !$curlResult->isSuccess()) { if (empty($curlResult) || !$curlResult->isSuccess()) {
return []; return [];
} }
} catch (\Throwable $th) { } catch (\Exception $exception) {
Logger::notice('Error fetching url', ['url' => $url, 'error' => $th]); Logger::notice('Error fetching url', ['url' => $url, 'exception' => $exception]);
return []; return [];
} }
$fields = ['mimetype' => $curlResult->getHeader('Content-Type')[0]]; $fields = ['mimetype' => $curlResult->getHeader('Content-Type')[0]];

View File

@ -120,8 +120,8 @@ class Statuses extends BaseApi
self::setBoundaries($item['uri-id']); self::setBoundaries($item['uri-id']);
try { try {
$statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes); $statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
} catch (\Throwable $th) { } catch (\Exception $exception) {
Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]); Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]);
} }
} }
DBA::close($items); DBA::close($items);

View File

@ -77,8 +77,8 @@ class Bookmarks extends BaseApi
self::setBoundaries($item['uri-id']); self::setBoundaries($item['uri-id']);
try { try {
$statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes); $statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
} catch (\Throwable $th) { } catch (\Exception $exception) {
Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]); Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]);
} }
} }
DBA::close($items); DBA::close($items);

View File

@ -79,8 +79,8 @@ class Favourited extends BaseApi
self::setBoundaries($item['thr-parent-id']); self::setBoundaries($item['thr-parent-id']);
try { try {
$statuses[] = DI::mstdnStatus()->createFromUriId($item['thr-parent-id'], $uid, $display_quotes); $statuses[] = DI::mstdnStatus()->createFromUriId($item['thr-parent-id'], $uid, $display_quotes);
} catch (\Throwable $th) { } catch (\Exception $exception) {
Logger::info('Post not fetchable', ['uri-id' => $item['thr-parent-id'], 'uid' => $uid, 'error' => $th]); Logger::info('Post not fetchable', ['uri-id' => $item['thr-parent-id'], 'uid' => $uid, 'exception' => $exception]);
} }
} }
DBA::close($items); DBA::close($items);

View File

@ -117,7 +117,7 @@ class Accounts extends BaseApi
self::setBoundaries($member['contact-id']); self::setBoundaries($member['contact-id']);
try { try {
$accounts[] = DI::mstdnAccount()->createFromContactId($member['contact-id'], $uid); $accounts[] = DI::mstdnAccount()->createFromContactId($member['contact-id'], $uid);
} catch (\Throwable $th) { } catch (\Exception $exception) {
} }
} }
DBA::close($members); DBA::close($members);

View File

@ -183,8 +183,8 @@ class Search extends BaseApi
self::setBoundaries($item['uri-id']); self::setBoundaries($item['uri-id']);
try { try {
$statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes); $statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
} catch (\Throwable $th) { } catch (\Exception $exception) {
Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]); Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]);
} }
} }
DBA::close($items); DBA::close($items);

View File

@ -99,8 +99,8 @@ class Home extends BaseApi
self::setBoundaries($item['uri-id']); self::setBoundaries($item['uri-id']);
try { try {
$statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes); $statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
} catch (\Throwable $th) { } catch (\Exception $exception) {
Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]); Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]);
} }
} }
DBA::close($items); DBA::close($items);

View File

@ -104,8 +104,8 @@ class ListTimeline extends BaseApi
self::setBoundaries($item['uri-id']); self::setBoundaries($item['uri-id']);
try { try {
$statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes); $statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
} catch (\Throwable $th) { } catch (\Exception $exception) {
Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]); Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]);
} }
} }
DBA::close($items); DBA::close($items);

View File

@ -99,8 +99,8 @@ class PublicTimeline extends BaseApi
self::setBoundaries($item['uri-id']); self::setBoundaries($item['uri-id']);
try { try {
$statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes); $statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
} catch (\Throwable $th) { } catch (\Exception $exception) {
Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]); Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]);
} }
} }
DBA::close($items); DBA::close($items);

View File

@ -120,8 +120,8 @@ class Tag extends BaseApi
self::setBoundaries($item['uri-id']); self::setBoundaries($item['uri-id']);
try { try {
$statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes); $statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
} catch (\Throwable $th) { } catch (\Exception $exception) {
Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]); Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]);
} }
} }
DBA::close($items); DBA::close($items);

View File

@ -57,8 +57,8 @@ class Statuses extends BaseApi
while ($status = Post::fetch($statuses)) { while ($status = Post::fetch($statuses)) {
try { try {
$trending[] = DI::mstdnStatus()->createFromUriId($status['uri-id'], $uid, $display_quotes); $trending[] = DI::mstdnStatus()->createFromUriId($status['uri-id'], $uid, $display_quotes);
} catch (\Throwable $th) { } catch (\Exception $exception) {
Logger::info('Post not fetchable', ['uri-id' => $status['uri-id'], 'uid' => $uid, 'error' => $th]); Logger::info('Post not fetchable', ['uri-id' => $status['uri-id'], 'uid' => $uid, 'exception' => $exception]);
} }
} }
DBA::close($statuses); DBA::close($statuses);

View File

@ -92,8 +92,8 @@ class Proxy extends BaseModule
self::responseError(); self::responseError();
// stop. // stop.
} }
} catch (\Throwable $th) { } catch (\Exception $exception) {
Logger::notice('Error fetching image', ['image' => $request['url'], 'error' => $th]); Logger::notice('Error fetching image', ['image' => $request['url'], 'exception' => $exception]);
self::responseError(); self::responseError();
} }

View File

@ -718,7 +718,7 @@ class Image
if ($image->isImagick()) { if ($image->isImagick()) {
try { try {
$colors = $image->image->getImagePixelColor($x, $y)->getColor(); $colors = $image->image->getImagePixelColor($x, $y)->getColor();
} catch (\Throwable $th) { } catch (\Exception $exception) {
return ''; return '';
} }
$row[] = [$colors['r'], $colors['g'], $colors['b']]; $row[] = [$colors['r'], $colors['g'], $colors['b']];

View File

@ -572,8 +572,8 @@ class Processor
{ {
try { try {
$curlResult = HTTPSignature::fetchRaw($url, 0); $curlResult = HTTPSignature::fetchRaw($url, 0);
} catch (\Throwable $th) { } catch (\Exception $exception) {
Logger::notice('Error fetching url', ['url' => $url, 'error' => $th]); Logger::notice('Error fetching url', ['url' => $url, 'exception' => $exception]);
return true; return true;
} }

View File

@ -424,8 +424,8 @@ class HTTPSignature
{ {
try { try {
$curlResult = self::fetchRaw($request, $uid); $curlResult = self::fetchRaw($request, $uid);
} catch (\Throwable $th) { } catch (\Exception $exception) {
Logger::notice('Error fetching url', ['url' => $request, 'error' => $th]); Logger::notice('Error fetching url', ['url' => $request, 'exception' => $exception]);
return []; return [];
} }