Merge pull request #4041 from lucasmichot/feat/try-catch

Remove some useless `catch` blocks
This commit is contained in:
Andras Bacsai
2024-10-28 21:15:08 +01:00
committed by GitHub
7 changed files with 230 additions and 263 deletions

View File

@@ -13,7 +13,6 @@ class StartProxy
public function handle(Server $server, bool $async = true, bool $force = false): string|Activity
{
try {
$proxyType = $server->proxyType();
if ((is_null($proxyType) || $proxyType === 'NONE' || $server->proxy->force_stop || $server->isBuildServer()) && $force === false) {
return 'OK';
@@ -71,8 +70,6 @@ class StartProxy
return 'OK';
}
} catch (\Throwable $e) {
throw $e;
}
}
}

View File

@@ -18,7 +18,6 @@ class UpdateCoolify
public function handle($manual_update = false)
{
try {
$settings = instanceSettings();
$this->server = Server::find(0);
if (! $this->server) {
@@ -41,9 +40,6 @@ class UpdateCoolify
$this->update();
$settings->new_version_available = false;
$settings->save();
} catch (\Throwable $e) {
throw $e;
}
}
private function update()

View File

@@ -112,7 +112,6 @@ class Controller extends BaseController
public function accept_invitation()
{
try {
$resetPassword = request()->query('reset-password');
$invitationUuid = request()->route('uuid');
$invitation = TeamInvitation::whereUuid($invitationUuid)->firstOrFail();
@@ -141,14 +140,10 @@ class Controller extends BaseController
} else {
abort(401);
}
} catch (\Throwable $e) {
throw $e;
}
}
public function revoke_invitation()
{
try {
$invitation = TeamInvitation::whereUuid(request()->route('uuid'))->firstOrFail();
$user = User::whereEmail($invitation->email)->firstOrFail();
if (is_null(auth()->user())) {
@@ -160,8 +155,5 @@ class Controller extends BaseController
$invitation->delete();
return redirect()->route('team.index');
} catch (\Throwable $e) {
throw $e;
}
}
}

View File

@@ -21,7 +21,6 @@ class CheckAndStartSentinelJob implements ShouldBeEncrypted, ShouldQueue
public function handle(): void
{
try {
$latestVersion = get_latest_sentinel_version();
// Check if sentinel is running
@@ -49,8 +48,5 @@ class CheckAndStartSentinelJob implements ShouldBeEncrypted, ShouldQueue
return;
}
}
} catch (\Throwable $e) {
throw $e;
}
}
}

View File

@@ -20,12 +20,8 @@ class PullHelperImageJob implements ShouldBeEncrypted, ShouldQueue
public function handle(): void
{
try {
$helperImage = config('coolify.helper_image');
$latest_version = instanceSettings()->helper_version;
instant_remote_process(["docker pull -q {$helperImage}:{$latest_version}"], $this->server, false);
} catch (\Throwable $e) {
throw $e;
}
}
}

View File

@@ -21,7 +21,6 @@ class PullVersionsFromCDN implements ShouldBeEncrypted, ShouldQueue
public function handle(): void
{
try {
if (! isDev() && ! isCloud()) {
$response = Http::retry(3, 1000)->get('https://cdn.coollabs.io/coolify/versions.json');
if ($response->successful()) {
@@ -31,8 +30,5 @@ class PullVersionsFromCDN implements ShouldBeEncrypted, ShouldQueue
send_internal_notification('PullTemplatesAndVersions failed with: '.$response->status().' '.$response->body());
}
}
} catch (\Throwable $e) {
throw $e;
}
}
}

View File

@@ -91,7 +91,6 @@ class PushServerUpdateJob implements ShouldBeEncrypted, ShouldQueue
public function handle()
{
// TODO: Swarm is not supported yet
try {
if (! $this->data) {
throw new \Exception('No data provided');
}
@@ -199,11 +198,6 @@ class PushServerUpdateJob implements ShouldBeEncrypted, ShouldQueue
$this->updateAdditionalServersStatus();
$this->checkLogDrainContainer();
} catch (\Exception $e) {
throw $e;
}
}
private function updateApplicationStatus(string $applicationId, string $containerStatus)