From d55b444bb81c6ac38a578e7b2fb5d2977a825d15 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 24 Oct 2024 15:08:22 +0200 Subject: [PATCH] Refactor ServerStorageCheckJob handle method to improve error handling and messaging --- app/Jobs/ServerStorageCheckJob.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/Jobs/ServerStorageCheckJob.php b/app/Jobs/ServerStorageCheckJob.php index 1330b7cde..32737cc47 100644 --- a/app/Jobs/ServerStorageCheckJob.php +++ b/app/Jobs/ServerStorageCheckJob.php @@ -31,8 +31,6 @@ class ServerStorageCheckJob implements ShouldBeEncrypted, ShouldQueue { try { if (! $this->server->isFunctional()) { - ray('Server is not ready.'); - return 'Server is not ready.'; } $team = data_get($this->server, 'team'); @@ -42,7 +40,7 @@ class ServerStorageCheckJob implements ShouldBeEncrypted, ShouldQueue $this->percentage = $this->server->storageCheck(); } if (! $this->percentage) { - throw new \Exception('No percentage could be retrieved.'); + return 'No percentage could be retrieved.'; } if ($this->percentage > $serverDiskUsageNotificationThreshold) { $executed = RateLimiter::attempt( @@ -55,7 +53,7 @@ class ServerStorageCheckJob implements ShouldBeEncrypted, ShouldQueue ); if (! $executed) { - throw new \Exception('Too many messages sent!'); + return 'Too many messages sent!'; } } else { RateLimiter::hit('high-disk-usage:'.$this->server->id, 600);