From ca5d9f3db5da0bbefdf1d5122438f86ef7c9cf9c Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 18 Sep 2026 12:17:14 +0930 Subject: [PATCH] MultiExceptionCatchRector --- app/Http/Controllers/RemoteAuthController.php | 4 +- app/Services/Account/RemoteAuthService.php | 42 ++++--------------- app/Services/ActivityPubFetchService.php | 6 +-- app/Services/CustomEmojiService.php | 4 +- app/Services/FetchCacheService.php | 10 +---- app/Services/Internal/BeagleService.php | 12 +----- .../Internal/SoftwareUpdateService.php | 6 +-- app/Services/NodeinfoService.php | 12 +----- .../NotificationAppGatewayService.php | 8 +--- app/Services/SecureMediaFetchService.php | 6 +-- 10 files changed, 19 insertions(+), 91 deletions(-) diff --git a/app/Http/Controllers/RemoteAuthController.php b/app/Http/Controllers/RemoteAuthController.php index 75f1f4893..5b2ea4c1d 100644 --- a/app/Http/Controllers/RemoteAuthController.php +++ b/app/Http/Controllers/RemoteAuthController.php @@ -566,9 +566,7 @@ class RemoteAuthController extends Controller } else { return []; } - } catch (RequestException) { - return []; - } catch (\Exception) { + } catch (RequestException|\Exception) { return []; } } diff --git a/app/Services/Account/RemoteAuthService.php b/app/Services/Account/RemoteAuthService.php index d05925a86..ca1e1ac6a 100644 --- a/app/Services/Account/RemoteAuthService.php +++ b/app/Services/Account/RemoteAuthService.php @@ -38,11 +38,7 @@ class RemoteAuthService if (! $res->ok()) { return false; } - } catch (RequestException) { - return false; - } catch (ConnectionException) { - return false; - } catch (\Exception) { + } catch (RequestException|ConnectionException|\Exception) { return false; } @@ -81,11 +77,7 @@ class RemoteAuthService 'redirect_uri' => $raw->redirect_uri, 'scope' => 'read', ]); - } catch (RequestException) { - return false; - } catch (ConnectionException) { - return false; - } catch (\Exception) { + } catch (RequestException|ConnectionException|\Exception) { return false; } @@ -106,11 +98,7 @@ class RemoteAuthService if (! $res->ok()) { return false; } - } catch (RequestException) { - return false; - } catch (ConnectionException) { - return false; - } catch (\Exception) { + } catch (RequestException|ConnectionException|\Exception) { return false; } @@ -133,11 +121,7 @@ class RemoteAuthService if (! $res->ok()) { return false; } - } catch (RequestException) { - return false; - } catch (ConnectionException) { - return false; - } catch (\Exception) { + } catch (RequestException|ConnectionException|\Exception) { return false; } @@ -168,11 +152,7 @@ class RemoteAuthService } return $json['compatible']; - } catch (RequestException) { - return false; - } catch (ConnectionException) { - return false; - } catch (\Exception) { + } catch (RequestException|ConnectionException|\Exception) { return false; } }); @@ -185,11 +165,7 @@ class RemoteAuthService if (! $res->ok()) { return false; } - } catch (RequestException) { - return false; - } catch (ConnectionException) { - return false; - } catch (\Exception) { + } catch (RequestException|ConnectionException|\Exception) { return false; } $json = $res->json(); @@ -214,11 +190,7 @@ class RemoteAuthService if (! $res->ok()) { return; } - } catch (RequestException) { - return; - } catch (ConnectionException) { - return; - } catch (\Exception) { + } catch (RequestException|ConnectionException|\Exception) { return; } diff --git a/app/Services/ActivityPubFetchService.php b/app/Services/ActivityPubFetchService.php index fad02f379..3513ea439 100644 --- a/app/Services/ActivityPubFetchService.php +++ b/app/Services/ActivityPubFetchService.php @@ -109,11 +109,7 @@ class ActivityPubFetchService ->connectTimeout(5) ->retry(2, 250) ->get($currentUrl); - } catch (RequestException $e) { - return; - } catch (ConnectionException $e) { - return; - } catch (\Throwable $e) { + } catch (RequestException|ConnectionException|\Throwable $e) { return; } diff --git a/app/Services/CustomEmojiService.php b/app/Services/CustomEmojiService.php index 8a461c56b..2f29b8c2a 100644 --- a/app/Services/CustomEmojiService.php +++ b/app/Services/CustomEmojiService.php @@ -77,9 +77,7 @@ class CustomEmojiService ->timeout(15) ->connectTimeout(5) ->get($url); - } catch (RequestException) { - return; - } catch (\Exception) { + } catch (RequestException|\Exception) { return; } diff --git a/app/Services/FetchCacheService.php b/app/Services/FetchCacheService.php index f9ac181c4..5bc3e4dfc 100644 --- a/app/Services/FetchCacheService.php +++ b/app/Services/FetchCacheService.php @@ -72,15 +72,7 @@ class FetchCacheService ->withHeaders($headers) ->timeout(40) ->get($url); - } catch (RequestException) { - Cache::put($key, 1, $ttl); - - return false; - } catch (ConnectionException) { - Cache::put($key, 1, $ttl); - - return false; - } catch (\Exception) { + } catch (RequestException|ConnectionException|\Exception) { Cache::put($key, 1, $ttl); return false; diff --git a/app/Services/Internal/BeagleService.php b/app/Services/Internal/BeagleService.php index 14cbc76f3..0790aeccb 100644 --- a/app/Services/Internal/BeagleService.php +++ b/app/Services/Internal/BeagleService.php @@ -28,11 +28,7 @@ class BeagleService ->connectTimeout(5) ->retry(2, 500) ->get('https://beagle.pixelfed.net/api/v1/common/suggestions/rules'); - } catch (RequestException) { - return; - } catch (ConnectionException) { - return; - } catch (\Exception) { + } catch (RequestException|ConnectionException|\Exception) { return; } @@ -69,11 +65,7 @@ class BeagleService ->connectTimeout(5) ->retry(2, 500) ->get('https://beagle.pixelfed.net/api/v1/discover'); - } catch (RequestException) { - return; - } catch (ConnectionException) { - return; - } catch (\Exception) { + } catch (RequestException|ConnectionException|\Exception) { return; } diff --git a/app/Services/Internal/SoftwareUpdateService.php b/app/Services/Internal/SoftwareUpdateService.php index 0d9c4fa45..48dc1e585 100644 --- a/app/Services/Internal/SoftwareUpdateService.php +++ b/app/Services/Internal/SoftwareUpdateService.php @@ -79,11 +79,7 @@ class SoftwareUpdateService ->connectTimeout(5) ->retry(2, 500) ->get('https://versions.pixelfed.org/versions.json'); - } catch (RequestException) { - return; - } catch (ConnectionException) { - return; - } catch (\Exception) { + } catch (RequestException|ConnectionException|\Exception) { return; } diff --git a/app/Services/NodeinfoService.php b/app/Services/NodeinfoService.php index 1ebf1db35..79775ddd5 100644 --- a/app/Services/NodeinfoService.php +++ b/app/Services/NodeinfoService.php @@ -28,11 +28,7 @@ class NodeinfoService ->withHeaders($headers) ->timeout(5) ->get($wk); - } catch (RequestException $e) { - return false; - } catch (ConnectionException $e) { - return false; - } catch (\Exception $e) { + } catch (RequestException|ConnectionException|\Exception $e) { return false; } @@ -77,11 +73,7 @@ class NodeinfoService ->withHeaders($headers) ->timeout(5) ->get($href); - } catch (RequestException) { - return false; - } catch (ConnectionException) { - return false; - } catch (\Exception) { + } catch (RequestException|ConnectionException|\Exception) { return false; } diff --git a/app/Services/NotificationAppGatewayService.php b/app/Services/NotificationAppGatewayService.php index 2ad798bc6..928a2c76f 100644 --- a/app/Services/NotificationAppGatewayService.php +++ b/app/Services/NotificationAppGatewayService.php @@ -44,9 +44,7 @@ class NotificationAppGatewayService ->get($endpoint); $data = $res->json(); - } catch (RequestException) { - return false; - } catch (Exception) { + } catch (RequestException|Exception) { return false; } @@ -120,9 +118,7 @@ class NotificationAppGatewayService ]); $response->throw(); - } catch (RequestException) { - return; - } catch (Exception) { + } catch (RequestException|Exception) { return; } } diff --git a/app/Services/SecureMediaFetchService.php b/app/Services/SecureMediaFetchService.php index 17be3df98..79f3f7f33 100644 --- a/app/Services/SecureMediaFetchService.php +++ b/app/Services/SecureMediaFetchService.php @@ -134,11 +134,7 @@ class SecureMediaFetchService ->timeout(self::TIMEOUT) ->connectTimeout(self::CONNECT_TIMEOUT) ->{$method}($currentUrl); - } catch (RequestException) { - return false; - } catch (ConnectionException) { - return false; - } catch (\Throwable) { + } catch (RequestException|ConnectionException|\Throwable) { return false; }