diff --git a/app/Repositories/Daemon/DaemonServerRepository.php b/app/Repositories/Daemon/DaemonServerRepository.php index ce91ece2bf..a22c20f28d 100644 --- a/app/Repositories/Daemon/DaemonServerRepository.php +++ b/app/Repositories/Daemon/DaemonServerRepository.php @@ -10,7 +10,6 @@ use Webmozart\Assert\Assert; use App\Models\Server; use GuzzleHttp\Exception\GuzzleException; -use GuzzleHttp\Exception\TransferException; use App\Exceptions\Http\Connection\DaemonConnectionException; class DaemonServerRepository extends DaemonRepository @@ -97,7 +96,7 @@ public function delete(): void try { $this->getHttpClient()->delete('/api/servers/' . $this->server->uuid); - } catch (TransferException $exception) { + } catch (GuzzleException $exception) { throw new DaemonConnectionException($exception); } } @@ -116,7 +115,7 @@ public function reinstall(): void '/api/servers/%s/reinstall', $this->server->uuid )); - } catch (TransferException $exception) { + } catch (GuzzleException $exception) { throw new DaemonConnectionException($exception); } } @@ -136,7 +135,7 @@ public function requestArchive(): void '/api/servers/%s/archive', $this->server->uuid )); - } catch (TransferException $exception) { + } catch (GuzzleException $exception) { throw new DaemonConnectionException($exception); } } @@ -159,7 +158,7 @@ public function cancelTransfer(): void '/api/servers/%s/transfer', $this->server->uuid )); - } catch (TransferException $exception) { + } catch (GuzzleException $exception) { throw new DaemonConnectionException($exception); } @@ -175,7 +174,7 @@ public function cancelTransfer(): void ], ], ]); - } catch (TransferException $exception) { + } catch (GuzzleException $exception) { throw new DaemonConnectionException($exception); } } @@ -210,7 +209,7 @@ protected function revokeJTIs(array $jtis): void ->post(sprintf('/api/servers/%s/ws/deny', $this->server->uuid), [ 'jtis' => $jtis, ]); - } catch (TransferException $exception) { + } catch (GuzzleException $exception) { throw new DaemonConnectionException($exception); } } diff --git a/app/Services/Servers/DetailsModificationService.php b/app/Services/Servers/DetailsModificationService.php index a9f3db1e12..dfaa4d5a1b 100644 --- a/app/Services/Servers/DetailsModificationService.php +++ b/app/Services/Servers/DetailsModificationService.php @@ -8,6 +8,7 @@ use App\Traits\Services\ReturnsUpdatedModels; use App\Repositories\Daemon\DaemonServerRepository; use App\Exceptions\Http\Connection\DaemonConnectionException; +use Illuminate\Http\Client\ConnectionException; class DetailsModificationService { @@ -41,7 +42,7 @@ public function handle(Server $server, array $data): Server if ($server->owner_id !== $owner) { try { $this->serverRepository->setServer($server)->revokeUserJTI($owner); - } catch (DaemonConnectionException $exception) { + } catch (ConnectionException|DaemonConnectionException) { // Do nothing. A failure here is not ideal, but it is likely to be caused by daemon // being offline, or in an entirely broken state. Remember, these tokens reset every // few minutes by default, we're just trying to help it along a little quicker. diff --git a/app/Services/Subusers/SubuserDeletionService.php b/app/Services/Subusers/SubuserDeletionService.php index 9ee67ac7d3..3f2ec9872e 100644 --- a/app/Services/Subusers/SubuserDeletionService.php +++ b/app/Services/Subusers/SubuserDeletionService.php @@ -8,6 +8,7 @@ use App\Models\Server; use App\Models\Subuser; use App\Repositories\Daemon\DaemonServerRepository; +use Illuminate\Http\Client\ConnectionException; class SubuserDeletionService { @@ -29,7 +30,7 @@ public function handle(Subuser $subuser, Server $server): void try { $this->serverRepository->setServer($server)->revokeUserJTI($subuser->user_id); - } catch (DaemonConnectionException $exception) { + } catch (ConnectionException|DaemonConnectionException $exception) { // Don't block this request if we can't connect to the daemon instance. logger()->warning($exception, ['user_id' => $subuser->user_id, 'server_id' => $server->id]); diff --git a/app/Services/Subusers/SubuserUpdateService.php b/app/Services/Subusers/SubuserUpdateService.php index 7c62b5eece..effbf0656b 100644 --- a/app/Services/Subusers/SubuserUpdateService.php +++ b/app/Services/Subusers/SubuserUpdateService.php @@ -7,6 +7,7 @@ use App\Models\Server; use App\Models\Subuser; use App\Repositories\Daemon\DaemonServerRepository; +use Illuminate\Http\Client\ConnectionException; class SubuserUpdateService { @@ -38,7 +39,7 @@ public function handle(Subuser $subuser, Server $server, array $permissions): vo try { $this->serverRepository->setServer($server)->revokeUserJTI($subuser->user_id); - } catch (DaemonConnectionException $exception) { + } catch (ConnectionException|DaemonConnectionException $exception) { // Don't block this request if we can't connect to the daemon instance. Chances are it is // offline and the token will be invalid once daemon boots back. logger()->warning($exception, ['user_id' => $subuser->user_id, 'server_id' => $server->id]);