1
1
Fork 0

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 {
$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;
}

View file

@ -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 {

View file

@ -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 {

View file

@ -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;
}

View file

@ -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'])) {

View file

@ -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]];

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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();
}

View file

@ -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']];

View file

@ -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;
}

View file

@ -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 [];
}