Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

Refactor ServerStorageCheckJob handle method to improve error handling and messaging

Andras Bacsaid55b444bb81c
diff --git a/app/Jobs/ServerStorageCheckJob.php b/app/Jobs/ServerStorageCheckJob.php
index 1330b7cde8..32737cc47d 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);