fix: errors

This commit is contained in:
Andras Bacsai
2023-09-11 17:36:30 +02:00
parent 16c71f3647
commit 64a65e2018
67 changed files with 156 additions and 147 deletions

View File

@@ -97,7 +97,6 @@ class RunRemoteProcess
'status' => $status->value, 'status' => $status->value,
]); ]);
$this->activity->save(); $this->activity->save();
if ($processResult->exitCode() != 0 && !$this->ignore_errors) { if ($processResult->exitCode() != 0 && !$this->ignore_errors) {
throw new \RuntimeException($processResult->errorOutput()); throw new \RuntimeException($processResult->errorOutput());
} }

View File

@@ -57,13 +57,13 @@ class CheckResaleLicense
throw new \Exception('Invalid license key.'); throw new \Exception('Invalid license key.');
} }
throw new \Exception('Cannot activate license key.'); throw new \Exception('Cannot activate license key.');
} catch (\Throwable $th) { } catch (\Throwable $e) {
ray($th); ray($e);
$settings->update([ $settings->update([
'resale_license' => null, 'resale_license' => null,
'is_resale_license_active' => false, 'is_resale_license_active' => false,
]); ]);
throw $th; throw $e;
} }
} }
} }

View File

@@ -20,8 +20,8 @@ class SaveConfigurationSync
"mkdir -p $proxy_path", "mkdir -p $proxy_path",
"echo '$docker_compose_yml_base64' | base64 -d > $proxy_path/docker-compose.yml", "echo '$docker_compose_yml_base64' | base64 -d > $proxy_path/docker-compose.yml",
], $server); ], $server);
} catch (\Throwable $th) { } catch (\Throwable $e) {
ray($th); ray($e);
} }
} }

View File

@@ -43,11 +43,11 @@ class UpdateCoolify
$this->update(); $this->update();
} }
send_internal_notification('InstanceAutoUpdateJob done to version: ' . $this->latestVersion . ' from version: ' . $this->currentVersion); send_internal_notification('InstanceAutoUpdateJob done to version: ' . $this->latestVersion . ' from version: ' . $this->currentVersion);
} catch (\Exception $th) { } catch (\Throwable $e) {
ray('InstanceAutoUpdateJob failed'); ray('InstanceAutoUpdateJob failed');
ray($th->getMessage()); ray($e->getMessage());
send_internal_notification('InstanceAutoUpdateJob failed: ' . $th->getMessage()); send_internal_notification('InstanceAutoUpdateJob failed: ' . $e->getMessage());
throw $th; throw $e;
} }
} }

View File

@@ -26,7 +26,7 @@ class Init extends Command
$deployment->status = ApplicationDeploymentStatus::FAILED->value; $deployment->status = ApplicationDeploymentStatus::FAILED->value;
$deployment->save(); $deployment->save();
} }
} catch (\Exception $e) { } catch (\Throwable $e) {
echo "Error: {$e->getMessage()}\n"; echo "Error: {$e->getMessage()}\n";
} }
} }

View File

@@ -82,7 +82,7 @@ class SyncBunny extends Command
$pool->purge("$bunny_cdn/$bunny_cdn_path/$versions"), $pool->purge("$bunny_cdn/$bunny_cdn_path/$versions"),
]); ]);
echo "All files uploaded & purged...\n"; echo "All files uploaded & purged...\n";
} catch (\Exception $e) { } catch (\Throwable $e) {
echo $e->getMessage(); echo $e->getMessage();
} }
} }

View File

@@ -25,7 +25,7 @@ class Handler extends ExceptionHandler
* @var array<int, class-string<\Throwable>> * @var array<int, class-string<\Throwable>>
*/ */
protected $dontReport = [ protected $dontReport = [
// ProcessException::class
]; ];
/** /**
* A list of the inputs that are never flashed to the session on validation exceptions. * A list of the inputs that are never flashed to the session on validation exceptions.

View File

@@ -0,0 +1,10 @@
<?php
namespace App\Exceptions;
use Exception;
class ProcessException extends Exception
{
}

View File

@@ -154,8 +154,8 @@ class Controller extends BaseController
$invitation->delete(); $invitation->delete();
abort(401); abort(401);
} }
} catch (Throwable $th) { } catch (Throwable $e) {
throw $th; throw $e;
} }
} }
@@ -172,8 +172,8 @@ class Controller extends BaseController
} }
$invitation->delete(); $invitation->delete();
return redirect()->route('team.index'); return redirect()->route('team.index');
} catch (Throwable $th) { } catch (Throwable $e) {
throw $th; throw $e;
} }
} }
} }

View File

@@ -193,7 +193,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
} }
$this->getProxyType(); $this->getProxyType();
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler(customErrorMessage: "Server is not reachable. Reason: {$e->getMessage()}", that: $this); return general_error_handler(customErrorMessage: "Server is not reachable. Reason: {$e->getMessage()}", that: $this);
} }
} }

View File

@@ -34,9 +34,9 @@ class CheckLicense extends Component
try { try {
resolve(CheckResaleLicense::class)(); resolve(CheckResaleLicense::class)();
$this->emit('reloadWindow'); $this->emit('reloadWindow');
} catch (\Throwable $th) { } catch (\Throwable $e) {
session()->flash('error', 'Something went wrong. Please contact support. <br>Error: ' . $th->getMessage()); session()->flash('error', 'Something went wrong. Please contact support. <br>Error: ' . $e->getMessage());
ray($th->getMessage()); ray($e->getMessage());
return redirect()->to('/settings/license'); return redirect()->to('/settings/license');
} }
} }

View File

@@ -37,7 +37,7 @@ class Form extends Component
} }
$this->destination->delete(); $this->destination->delete();
return redirect()->route('dashboard'); return redirect()->route('dashboard');
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler(err: $e); return general_error_handler(err: $e);
} }
} }

View File

@@ -71,7 +71,7 @@ class StandaloneDocker extends Component
} }
$this->createNetworkAndAttachToProxy(); $this->createNetworkAndAttachToProxy();
return redirect()->route('destination.show', $docker->uuid); return redirect()->route('destination.show', $docker->uuid);
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler(err: $e, that: $this); return general_error_handler(err: $e, that: $this);
} }
} }

View File

@@ -36,7 +36,7 @@ class ForcePasswordReset extends Component
send_internal_notification('First login for ' . auth()->user()->email); send_internal_notification('First login for ' . auth()->user()->email);
} }
return redirect()->route('dashboard'); return redirect()->route('dashboard');
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler(err: $e, that: $this); return general_error_handler(err: $e, that: $this);
} }
} }

View File

@@ -43,7 +43,7 @@ class Help extends Component
$mail->subject("[HELP - {$subscriptionType}]: {$this->subject}"); $mail->subject("[HELP - {$subscriptionType}]: {$this->subject}");
send_user_an_email($mail, 'hi@coollabs.io'); send_user_an_email($mail, 'hi@coollabs.io');
$this->emit('success', 'Your message has been sent successfully. We will get in touch with you as soon as possible.'); $this->emit('success', 'Your message has been sent successfully. We will get in touch with you as soon as possible.');
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler($e, $this); return general_error_handler($e, $this);
} }
} }

View File

@@ -29,7 +29,7 @@ class DiscordSettings extends Component
{ {
try { try {
$this->submit(); $this->submit();
} catch (\Exception $e) { } catch (\Throwable $e) {
ray($e->getMessage()); ray($e->getMessage());
$this->team->discord_enabled = false; $this->team->discord_enabled = false;
$this->validate(); $this->validate();

View File

@@ -63,7 +63,7 @@ class EmailSettings extends Component
]); ]);
$this->team->save(); $this->team->save();
$this->emit('success', 'Settings saved successfully.'); $this->emit('success', 'Settings saved successfully.');
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler($e, $this); return general_error_handler($e, $this);
} }
} }
@@ -82,7 +82,7 @@ class EmailSettings extends Component
$this->team->resend_enabled = false; $this->team->resend_enabled = false;
$this->team->save(); $this->team->save();
$this->emit('success', 'Settings saved successfully.'); $this->emit('success', 'Settings saved successfully.');
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler($e, $this); return general_error_handler($e, $this);
} }
} }
@@ -92,7 +92,7 @@ class EmailSettings extends Component
try { try {
$this->team->smtp_enabled = false; $this->team->smtp_enabled = false;
$this->submitResend(); $this->submitResend();
} catch (\Exception $e) { } catch (\Throwable $e) {
$this->team->smtp_enabled = false; $this->team->smtp_enabled = false;
return general_error_handler($e, $this); return general_error_handler($e, $this);
} }
@@ -102,7 +102,7 @@ class EmailSettings extends Component
try { try {
$this->team->resend_enabled = false; $this->team->resend_enabled = false;
$this->submit(); $this->submit();
} catch (\Exception $e) { } catch (\Throwable $e) {
$this->team->smtp_enabled = false; $this->team->smtp_enabled = false;
return general_error_handler($e, $this); return general_error_handler($e, $this);
} }
@@ -131,7 +131,7 @@ class EmailSettings extends Component
]); ]);
$this->team->save(); $this->team->save();
$this->emit('success', 'Settings saved successfully.'); $this->emit('success', 'Settings saved successfully.');
} catch (\Exception $e) { } catch (\Throwable $e) {
$this->team->smtp_enabled = false; $this->team->smtp_enabled = false;
return general_error_handler($e, $this); return general_error_handler($e, $this);
} }
@@ -146,7 +146,7 @@ class EmailSettings extends Component
$this->team->save(); $this->team->save();
refreshSession(); refreshSession();
$this->emit('success', 'Settings saved successfully.'); $this->emit('success', 'Settings saved successfully.');
} catch (\Exception $e) { } catch (\Throwable $e) {
$this->team->resend_enabled = false; $this->team->resend_enabled = false;
return general_error_handler($e, $this); return general_error_handler($e, $this);
} }

View File

@@ -35,7 +35,7 @@ class TelegramSettings extends Component
{ {
try { try {
$this->submit(); $this->submit();
} catch (\Exception $e) { } catch (\Throwable $e) {
ray($e->getMessage()); ray($e->getMessage());
$this->team->telegram_enabled = false; $this->team->telegram_enabled = false;
$this->validate(); $this->validate();

View File

@@ -38,7 +38,7 @@ class Change extends Component
return redirect()->route('security.private-key.index'); return redirect()->route('security.private-key.index');
} }
$this->emit('error', 'This private key is in use and cannot be deleted. Please delete all servers, applications, and GitHub/GitLab apps that use this private key before deleting it.'); $this->emit('error', 'This private key is in use and cannot be deleted. Please delete all servers, applications, and GitHub/GitLab apps that use this private key before deleting it.');
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler(err: $e, that: $this); return general_error_handler(err: $e, that: $this);
} }
} }
@@ -49,7 +49,7 @@ class Change extends Component
$this->private_key->private_key = formatPrivateKey($this->private_key->private_key); $this->private_key->private_key = formatPrivateKey($this->private_key->private_key);
$this->private_key->save(); $this->private_key->save();
refresh_server_connection($this->private_key); refresh_server_connection($this->private_key);
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler(err: $e, that: $this); return general_error_handler(err: $e, that: $this);
} }
} }

View File

@@ -38,7 +38,7 @@ class Create extends Component
return redirect()->route('server.create'); return redirect()->route('server.create');
} }
return redirect()->route('security.private-key.show', ['private_key_uuid' => $private_key->uuid]); return redirect()->route('security.private-key.show', ['private_key_uuid' => $private_key->uuid]);
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler(err: $e, that: $this); return general_error_handler(err: $e, that: $this);
} }
} }

View File

@@ -28,7 +28,7 @@ class AddEmpty extends Component
'team_id' => currentTeam()->id, 'team_id' => currentTeam()->id,
]); ]);
return redirect()->route('project.show', $project->uuid); return redirect()->route('project.show', $project->uuid);
} catch (\Exception $e) { } catch (\Throwable $e) {
general_error_handler($e, $this); general_error_handler($e, $this);
} finally { } finally {
$this->name = ''; $this->name = '';

View File

@@ -31,7 +31,7 @@ class AddEnvironment extends Component
'project_uuid' => $this->project->uuid, 'project_uuid' => $this->project->uuid,
'environment_name' => $environment->name, 'environment_name' => $environment->name,
]); ]);
} catch (\Exception $e) { } catch (\Throwable $e) {
general_error_handler($e, $this); general_error_handler($e, $this);
} finally { } finally {
$this->name = ''; $this->name = '';

View File

@@ -161,7 +161,7 @@ class General extends Component
} }
$this->application->save(); $this->application->save();
$this->emit('success', 'Application settings updated!'); $this->emit('success', 'Application settings updated!');
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler(err: $e, that: $this); return general_error_handler(err: $e, that: $this);
} }
} }

View File

@@ -51,7 +51,7 @@ class BackupEdit extends Component
$this->backup->save(); $this->backup->save();
$this->backup->refresh(); $this->backup->refresh();
$this->emit('success', 'Backup updated successfully'); $this->emit('success', 'Backup updated successfully');
} catch (\Exception $e) { } catch (\Throwable $e) {
$this->emit('error', $e->getMessage()); $this->emit('error', $e->getMessage());
} }
} }
@@ -76,7 +76,7 @@ class BackupEdit extends Component
$this->backup->save(); $this->backup->save();
$this->backup->refresh(); $this->backup->refresh();
$this->emit('success', 'Backup updated successfully'); $this->emit('success', 'Backup updated successfully');
} catch (\Exception $e) { } catch (\Throwable $e) {
$this->emit('error', $e->getMessage()); $this->emit('error', $e->getMessage());
} }
} }

View File

@@ -42,7 +42,7 @@ class CreateScheduledBackup extends Component
'team_id' => currentTeam()->id, 'team_id' => currentTeam()->id,
]); ]);
$this->emit('refreshScheduledBackups'); $this->emit('refreshScheduledBackups');
} catch (\Exception $e) { } catch (\Throwable $e) {
general_error_handler($e, $this); general_error_handler($e, $this);
} finally { } finally {
$this->frequency = ''; $this->frequency = '';

View File

@@ -19,7 +19,7 @@ class Edit extends Component
try { try {
$this->project->save(); $this->project->save();
$this->emit('saved'); $this->emit('saved');
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler($e, $this); return general_error_handler($e, $this);
} }
} }

View File

@@ -164,7 +164,7 @@ class GithubPrivateRepository extends Component
'environment_name' => $environment->name, 'environment_name' => $environment->name,
'project_uuid' => $project->uuid, 'project_uuid' => $project->uuid,
]); ]);
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler(err: $e, that: $this); return general_error_handler(err: $e, that: $this);
} }
} }

View File

@@ -117,7 +117,7 @@ class GithubPrivateRepositoryDeployKey extends Component
'environment_name' => $environment->name, 'environment_name' => $environment->name,
'application_uuid' => $application->uuid, 'application_uuid' => $application->uuid,
]); ]);
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler(err: $e, that: $this); return general_error_handler(err: $e, that: $this);
} }
} }

View File

@@ -75,14 +75,14 @@ class PublicGitRepository extends Component
$this->get_git_source(); $this->get_git_source();
$this->get_branch(); $this->get_branch();
$this->selected_branch = $this->git_branch; $this->selected_branch = $this->git_branch;
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler(err: $e, that: $this); return general_error_handler(err: $e, that: $this);
} }
if (!$this->branch_found && $this->git_branch == 'main') { if (!$this->branch_found && $this->git_branch == 'main') {
try { try {
$this->git_branch = 'master'; $this->git_branch = 'master';
$this->get_branch(); $this->get_branch();
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler(err: $e, that: $this); return general_error_handler(err: $e, that: $this);
} }
} }
@@ -161,7 +161,7 @@ class PublicGitRepository extends Component
'environment_name' => $environment->name, 'environment_name' => $environment->name,
'application_uuid' => $application->uuid, 'application_uuid' => $application->uuid,
]); ]);
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler(err: $e, that: $this); return general_error_handler(err: $e, that: $this);
} }
} }

View File

@@ -40,7 +40,7 @@ class Select extends Component
// try { // try {
// instantCommand("psql {$this->existingPostgresqlUrl} -c 'SELECT 1'"); // instantCommand("psql {$this->existingPostgresqlUrl} -c 'SELECT 1'");
// $this->emit('success', 'Successfully connected to the database.'); // $this->emit('success', 'Successfully connected to the database.');
// } catch (\Exception $e) { // } catch (\Throwable $e) {
// return general_error_handler($e, $this); // return general_error_handler($e, $this);
// } // }
// } // }

View File

@@ -108,7 +108,7 @@ class All extends Component
$environment->save(); $environment->save();
$this->refreshEnvs(); $this->refreshEnvs();
$this->emit('success', 'Environment variable added successfully.'); $this->emit('success', 'Environment variable added successfully.');
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler(err: $e, that: $this); return general_error_handler(err: $e, that: $this);
} }
} }

View File

@@ -53,7 +53,7 @@ class ResourceLimits extends Component
$this->validate(); $this->validate();
$this->resource->save(); $this->resource->save();
$this->emit('success', 'Resource limits updated successfully.'); $this->emit('success', 'Resource limits updated successfully.');
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler(err: $e, that: $this); return general_error_handler(err: $e, that: $this);
} }
} }

View File

@@ -28,7 +28,7 @@ class All extends Component
$this->resource->refresh(); $this->resource->refresh();
$this->emit('success', 'Storage added successfully'); $this->emit('success', 'Storage added successfully');
$this->emit('clearAddStorage'); $this->emit('clearAddStorage');
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler(err: $e, that: $this); return general_error_handler(err: $e, that: $this);
} }
} }

View File

@@ -32,7 +32,7 @@ class RunCommand extends Component
try { try {
$activity = remote_process([$this->command], Server::where('uuid', $this->server)->first(), ignore_errors: true); $activity = remote_process([$this->command], Server::where('uuid', $this->server)->first(), ignore_errors: true);
$this->emit('newMonitorActivity', $activity->id); $this->emit('newMonitorActivity', $activity->id);
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler(err: $e); return general_error_handler(err: $e);
} }
} }

View File

@@ -66,7 +66,7 @@ class Form extends Component
} else { } else {
$this->emit('error', 'Old (lower than 23) or no Docker version detected. Install Docker Engine on the General tab.'); $this->emit('error', 'Old (lower than 23) or no Docker version detected. Install Docker Engine on the General tab.');
} }
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler($e, that: $this); return general_error_handler($e, that: $this);
} }
} }
@@ -81,7 +81,7 @@ class Form extends Component
} }
$this->server->delete(); $this->server->delete();
return redirect()->route('server.all'); return redirect()->route('server.all');
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler(err: $e, that: $this); return general_error_handler(err: $e, that: $this);
} }
} }

View File

@@ -78,7 +78,7 @@ class ByIp extends Component
$server->settings->is_part_of_swarm = $this->is_part_of_swarm; $server->settings->is_part_of_swarm = $this->is_part_of_swarm;
$server->settings->save(); $server->settings->save();
return redirect()->route('server.show', $server->uuid); return redirect()->route('server.show', $server->uuid);
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler(err: $e); return general_error_handler(err: $e);
} }
} }

View File

@@ -55,7 +55,7 @@ class Proxy extends Component
setup_default_redirect_404(redirect_url: $this->server->proxy->redirect_url, server: $this->server); setup_default_redirect_404(redirect_url: $this->server->proxy->redirect_url, server: $this->server);
$this->emit('success', 'Proxy configuration saved.'); $this->emit('success', 'Proxy configuration saved.');
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler(err: $e); return general_error_handler(err: $e);
} }
} }
@@ -64,7 +64,7 @@ class Proxy extends Component
{ {
try { try {
$this->proxy_settings = resolve(CheckConfigurationSync::class)($this->server, true); $this->proxy_settings = resolve(CheckConfigurationSync::class)($this->server, true);
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler(err: $e); return general_error_handler(err: $e);
} }
} }
@@ -73,7 +73,7 @@ class Proxy extends Component
{ {
try { try {
$this->proxy_settings = resolve(CheckConfigurationSync::class)($this->server); $this->proxy_settings = resolve(CheckConfigurationSync::class)($this->server);
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler(err: $e); return general_error_handler(err: $e);
} }
} }

View File

@@ -21,7 +21,7 @@ class ShowPrivateKey extends Component
$this->server->refresh(); $this->server->refresh();
refresh_server_connection($this->server->privateKey); refresh_server_connection($this->server->privateKey);
$this->checkConnection(); $this->checkConnection();
} catch (\Exception $e) { } catch (\Throwable $e) {
$this->server->update([ $this->server->update([
'private_key_id' => $oldPrivateKeyId 'private_key_id' => $oldPrivateKeyId
]); ]);
@@ -46,7 +46,7 @@ class ShowPrivateKey extends Component
} else { } else {
$this->emit('error', 'Old (lower than 23) or no Docker version detected. Install Docker Engine on the General tab.'); $this->emit('error', 'Old (lower than 23) or no Docker version detected. Install Docker Engine on the General tab.');
} }
} catch (\Exception $e) { } catch (\Throwable $e) {
throw new \Exception($e->getMessage()); throw new \Exception($e->getMessage());
} }
} }

View File

@@ -50,7 +50,7 @@ class Email extends Component
]); ]);
$this->settings->save(); $this->settings->save();
$this->emit('success', 'Settings saved successfully.'); $this->emit('success', 'Settings saved successfully.');
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler($e, $this); return general_error_handler($e, $this);
} }
} }
@@ -62,7 +62,7 @@ class Email extends Component
]); ]);
$this->settings->save(); $this->settings->save();
$this->emit('success', 'Settings saved successfully.'); $this->emit('success', 'Settings saved successfully.');
} catch (\Exception $e) { } catch (\Throwable $e) {
$this->settings->resend_enabled = false; $this->settings->resend_enabled = false;
return general_error_handler($e, $this); return general_error_handler($e, $this);
} }
@@ -71,7 +71,7 @@ class Email extends Component
try { try {
$this->settings->smtp_enabled = false; $this->settings->smtp_enabled = false;
$this->submitResend(); $this->submitResend();
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler($e, $this); return general_error_handler($e, $this);
} }
} }
@@ -80,7 +80,7 @@ class Email extends Component
try { try {
$this->settings->resend_enabled = false; $this->settings->resend_enabled = false;
$this->submit(); $this->submit();
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler($e, $this); return general_error_handler($e, $this);
} }
} }
@@ -99,7 +99,7 @@ class Email extends Component
]); ]);
$this->settings->save(); $this->settings->save();
$this->emit('success', 'Settings saved successfully.'); $this->emit('success', 'Settings saved successfully.');
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler($e, $this); return general_error_handler($e, $this);
} }
} }

View File

@@ -51,7 +51,7 @@ class Change extends Component
try { try {
$this->validate(); $this->validate();
$this->github_app->save(); $this->github_app->save();
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler(err: $e, that: $this); return general_error_handler(err: $e, that: $this);
} }
} }
@@ -65,7 +65,7 @@ class Change extends Component
try { try {
$this->github_app->delete(); $this->github_app->delete();
redirect()->route('source.all'); redirect()->route('source.all');
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler(err: $e, that: $this); return general_error_handler(err: $e, that: $this);
} }
} }

View File

@@ -49,7 +49,7 @@ class Create extends Component
session(['from' => session('from') + ['source_id' => $github_app->id]]); session(['from' => session('from') + ['source_id' => $github_app->id]]);
} }
redirect()->route('source.github.show', ['github_app_uuid' => $github_app->uuid]); redirect()->route('source.github.show', ['github_app_uuid' => $github_app->uuid]);
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler(err: $e, that: $this); return general_error_handler(err: $e, that: $this);
} }
} }

View File

@@ -30,7 +30,7 @@ class Actions extends Component
$this->emit('success', 'Subscription cancelled successfully. Reloading in 5s.'); $this->emit('success', 'Subscription cancelled successfully. Reloading in 5s.');
$this->emit('reloadWindow', 5000); $this->emit('reloadWindow', 5000);
} }
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler($e, $this); return general_error_handler($e, $this);
} }
} }
@@ -65,7 +65,7 @@ class Actions extends Component
$this->emit('success', 'Subscription resumed successfully. Reloading in 5s.'); $this->emit('success', 'Subscription resumed successfully. Reloading in 5s.');
$this->emit('reloadWindow', 5000); $this->emit('reloadWindow', 5000);
} }
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler($e, $this); return general_error_handler($e, $this);
} }
} }

View File

@@ -31,8 +31,8 @@ class Create extends Component
auth()->user()->teams()->attach($team, ['role' => 'admin']); auth()->user()->teams()->attach($team, ['role' => 'admin']);
refreshSession(); refreshSession();
return redirect()->route('team.index'); return redirect()->route('team.index');
} catch (\Throwable $th) { } catch (\Throwable $e) {
return general_error_handler($th, $this); return general_error_handler($e, $this);
} }
} }
} }

View File

@@ -28,8 +28,8 @@ class Form extends Component
try { try {
$this->team->save(); $this->team->save();
refreshSession(); refreshSession();
} catch (\Throwable $th) { } catch (\Throwable $e) {
return general_error_handler($th, $this); return general_error_handler($e, $this);
} }
} }
} }

View File

@@ -67,8 +67,8 @@ class Create extends Component
$this->emit('success', 'Connection is working. Tested with "ListObjectsV2" action.'); $this->emit('success', 'Connection is working. Tested with "ListObjectsV2" action.');
$this->storage->save(); $this->storage->save();
return redirect()->route('team.storages.show', $this->storage->uuid); return redirect()->route('team.storages.show', $this->storage->uuid);
} catch (\Throwable $th) { } catch (\Throwable $e) {
return general_error_handler($th, $this); return general_error_handler($e, $this);
} }
} }
@@ -77,8 +77,8 @@ class Create extends Component
try { try {
$this->storage->testConnection(); $this->storage->testConnection();
return $this->emit('success', 'Connection is working. Tested with "ListObjectsV2" action.'); return $this->emit('success', 'Connection is working. Tested with "ListObjectsV2" action.');
} catch (\Throwable $th) { } catch (\Throwable $e) {
return general_error_handler($th, $this); return general_error_handler($e, $this);
} }
} }
} }

View File

@@ -32,8 +32,8 @@ class Form extends Component
try { try {
$this->storage->testConnection(); $this->storage->testConnection();
return $this->emit('success', 'Connection is working. Tested with "ListObjectsV2" action.'); return $this->emit('success', 'Connection is working. Tested with "ListObjectsV2" action.');
} catch (\Throwable $th) { } catch (\Throwable $e) {
return general_error_handler($th, $this); return general_error_handler($e, $this);
} }
} }
@@ -42,8 +42,8 @@ class Form extends Component
try { try {
$this->storage->delete(); $this->storage->delete();
return redirect()->route('team.storages.all'); return redirect()->route('team.storages.all');
} catch (\Throwable $th) { } catch (\Throwable $e) {
return general_error_handler($th, $this); return general_error_handler($e, $this);
} }
} }
@@ -55,8 +55,8 @@ class Form extends Component
$this->emit('success', 'Connection is working. Tested with "ListObjectsV2" action.'); $this->emit('success', 'Connection is working. Tested with "ListObjectsV2" action.');
$this->storage->save(); $this->storage->save();
$this->emit('success', 'Storage settings saved.'); $this->emit('success', 'Storage settings saved.');
} catch (\Throwable $th) { } catch (\Throwable $e) {
return general_error_handler($th, $this); return general_error_handler($e, $this);
} }
} }
} }

View File

@@ -37,7 +37,7 @@ class Upgrade extends Component
$this->showProgress = true; $this->showProgress = true;
resolve(UpdateCoolify::class)(true); resolve(UpdateCoolify::class)(true);
Toaster::success("Upgrading to {$this->latestVersion} version..."); Toaster::success("Upgrading to {$this->latestVersion} version...");
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler(err: $e, that: $this); return general_error_handler(err: $e, that: $this);
} }
} }

View File

@@ -52,7 +52,7 @@ class Index extends Component
$this->emit('success', 'Check your email to verify your email address.'); $this->emit('success', 'Check your email to verify your email address.');
dispatch(new SendConfirmationForWaitlistJob($this->email, $waitlist->uuid)); dispatch(new SendConfirmationForWaitlistJob($this->email, $waitlist->uuid));
} catch (\Exception $e) { } catch (\Throwable $e) {
return general_error_handler(err: $e, that: $this); return general_error_handler(err: $e, that: $this);
} }
} }

View File

@@ -46,9 +46,9 @@ class ApplicationContainerStatusJob implements ShouldQueue, ShouldBeUnique
$this->application->status = $status; $this->application->status = $status;
$this->application->save(); $this->application->save();
} }
} catch (\Exception $th) { } catch (\Throwable $e) {
ray($th->getMessage()); ray($e->getMessage());
throw $th; throw $e;
} }
} }
} }

View File

@@ -57,7 +57,7 @@ class ApplicationPullRequestUpdateJob implements ShouldQueue
} else { } else {
$this->create_comment(); $this->create_comment();
} }
} catch (\Exception $e) { } catch (\Throwable $e) {
ray($e); ray($e);
throw $e; throw $e;
} }

View File

@@ -21,10 +21,10 @@ class CheckResaleLicenseJob implements ShouldQueue
{ {
try { try {
resolve(CheckResaleLicense::class)(); resolve(CheckResaleLicense::class)();
} catch (\Throwable $th) { } catch (\Throwable $e) {
send_internal_notification('CheckResaleLicenseJob failed with: ' . $th->getMessage()); send_internal_notification('CheckResaleLicenseJob failed with: ' . $e->getMessage());
ray($th); ray($e);
throw $th; throw $e;
} }
} }
} }

View File

@@ -28,7 +28,7 @@ class CleanupInstanceStuffsJob implements ShouldQueue, ShouldBeUnique
{ {
try { try {
// $this->cleanup_waitlist(); // $this->cleanup_waitlist();
} catch (\Exception $e) { } catch (\Throwable $e) {
send_internal_notification('CleanupInstanceStuffsJob failed with error: ' . $e->getMessage()); send_internal_notification('CleanupInstanceStuffsJob failed with error: ' . $e->getMessage());
ray($e->getMessage()); ray($e->getMessage());
throw $e; throw $e;

View File

@@ -90,10 +90,10 @@ class DatabaseBackupJob implements ShouldQueue
} }
$this->save_backup_logs(); $this->save_backup_logs();
// TODO: Notify user // TODO: Notify user
} catch (\Throwable $th) { } catch (\Throwable $e) {
ray($th->getMessage()); ray($e->getMessage());
send_internal_notification('DatabaseBackupJob failed with: ' . $th->getMessage()); send_internal_notification('DatabaseBackupJob failed with: ' . $e->getMessage());
throw $th; throw $e;
} }
} }
@@ -116,10 +116,10 @@ class DatabaseBackupJob implements ShouldQueue
$this->backup_status = 'success'; $this->backup_status = 'success';
$this->team->notify(new BackupSuccess($this->backup, $this->database)); $this->team->notify(new BackupSuccess($this->backup, $this->database));
} catch (Throwable $th) { } catch (Throwable $e) {
$this->backup_status = 'failed'; $this->backup_status = 'failed';
$this->add_to_backup_output($th->getMessage()); $this->add_to_backup_output($e->getMessage());
ray('Backup failed for ' . $this->container_name . ' at ' . $this->server->name . ':' . $this->backup_location . '\n\nError:' . $th->getMessage()); ray('Backup failed for ' . $this->container_name . ' at ' . $this->server->name . ':' . $this->backup_location . '\n\nError:' . $e->getMessage());
$this->team->notify(new BackupFailed($this->backup, $this->database, $this->backup_output)); $this->team->notify(new BackupFailed($this->backup, $this->database, $this->backup_output));
} finally { } finally {
$this->backup_log->update([ $this->backup_log->update([
@@ -173,9 +173,9 @@ class DatabaseBackupJob implements ShouldQueue
instant_remote_process($commands, $this->server); instant_remote_process($commands, $this->server);
$this->add_to_backup_output('Uploaded to S3.'); $this->add_to_backup_output('Uploaded to S3.');
ray('Uploaded to S3. ' . $this->backup_location . ' to s3://' . $bucket . $this->backup_dir); ray('Uploaded to S3. ' . $this->backup_location . ' to s3://' . $bucket . $this->backup_dir);
} catch (\Throwable $th) { } catch (\Throwable $e) {
$this->add_to_backup_output($th->getMessage()); $this->add_to_backup_output($e->getMessage());
ray($th->getMessage()); ray($e->getMessage());
} finally { } finally {
$command = "docker rm -f backup-of-{$this->backup->uuid}"; $command = "docker rm -f backup-of-{$this->backup->uuid}";
instant_remote_process([$command], $this->server); instant_remote_process([$command], $this->server);

View File

@@ -47,7 +47,7 @@ class DatabaseContainerStatusJob implements ShouldQueue, ShouldBeUnique
$this->database->status = $status; $this->database->status = $status;
$this->database->save(); $this->database->save();
} }
} catch (\Exception $e) { } catch (\Throwable $e) {
send_internal_notification('DatabaseContainerStatusJob failed with: ' . $e->getMessage()); send_internal_notification('DatabaseContainerStatusJob failed with: ' . $e->getMessage());
ray($e->getMessage()); ray($e->getMessage());
throw $e; throw $e;

View File

@@ -75,7 +75,7 @@ class DockerCleanupJob implements ShouldQueue
ray('No need to clean up ' . $server->name)->color('orange'); ray('No need to clean up ' . $server->name)->color('orange');
} }
} }
} catch (\Exception $e) { } catch (\Throwable $e) {
send_internal_notification('DockerCleanupJob failed with: ' . $e->getMessage()); send_internal_notification('DockerCleanupJob failed with: ' . $e->getMessage());
ray($e->getMessage())->color('orange'); ray($e->getMessage())->color('orange');
throw $e; throw $e;

View File

@@ -37,10 +37,10 @@ class ProxyCheckJob implements ShouldQueue
resolve(StartProxy::class)($server); resolve(StartProxy::class)($server);
} }
} }
} catch (\Throwable $th) { } catch (\Throwable $e) {
ray($th->getMessage()); ray($e->getMessage());
send_internal_notification('ProxyCheckJob failed with: ' . $th->getMessage()); send_internal_notification('ProxyCheckJob failed with: ' . $e->getMessage());
throw $th; throw $e;
} }
} }
} }

View File

@@ -52,7 +52,7 @@ class ProxyContainerStatusJob implements ShouldQueue, ShouldBeUnique
} }
$this->server->save(); $this->server->save();
} }
} catch (\Exception $e) { } catch (\Throwable $e) {
if ($e->getCode() === 1) { if ($e->getCode() === 1) {
$this->server->proxy->status = 'exited'; $this->server->proxy->status = 'exited';
$this->server->save(); $this->server->save();

View File

@@ -35,10 +35,10 @@ class ProxyStartJob implements ShouldQueue
$this->server->save(); $this->server->save();
} }
resolve(StartProxy::class)($this->server); resolve(StartProxy::class)($this->server);
} catch (\Throwable $th) { } catch (\Throwable $e) {
send_internal_notification('ProxyStartJob failed with: ' . $th->getMessage()); send_internal_notification('ProxyStartJob failed with: ' . $e->getMessage());
ray($th->getMessage()); ray($e->getMessage());
throw $th; throw $e;
} }
} }
} }

View File

@@ -37,10 +37,10 @@ class ResourceStatusJob implements ShouldQueue, ShouldBeUnique
database: $postgresql, database: $postgresql,
)); ));
} }
} catch (\Exception $th) { } catch (\Throwable $e) {
send_internal_notification('ResourceStatusJob failed with: ' . $th->getMessage()); send_internal_notification('ResourceStatusJob failed with: ' . $e->getMessage());
ray($th); ray($e);
throw $th; throw $e;
} }
} }
} }

View File

@@ -34,10 +34,10 @@ class SendConfirmationForWaitlistJob implements ShouldQueue
]); ]);
$mail->subject('You are on the waitlist!'); $mail->subject('You are on the waitlist!');
send_user_an_email($mail, $this->email); send_user_an_email($mail, $this->email);
} catch (\Throwable $th) { } catch (\Throwable $e) {
send_internal_notification("SendConfirmationForWaitlistJob failed for {$this->email} with error: " . $th->getMessage()); send_internal_notification("SendConfirmationForWaitlistJob failed for {$this->email} with error: " . $e->getMessage());
ray($th->getMessage()); ray($e->getMessage());
throw $th; throw $e;
} }
} }
} }

View File

@@ -33,10 +33,10 @@ class SubscriptionInvoiceFailedJob implements ShouldQueue
send_user_an_email($mail, $member->email); send_user_an_email($mail, $member->email);
} }
}); });
} catch (\Throwable $th) { } catch (\Throwable $e) {
send_internal_notification('SubscriptionInvoiceFailedJob failed with: ' . $th->getMessage()); send_internal_notification('SubscriptionInvoiceFailedJob failed with: ' . $e->getMessage());
ray($th->getMessage()); ray($e->getMessage());
throw $th; throw $e;
} }
} }
} }

View File

@@ -24,7 +24,7 @@ class PrivateKey extends BaseModel
{ {
try { try {
return PublicKeyLoader::load($this->private_key)->getPublicKey()->toString('OpenSSH',['comment' => '']); return PublicKeyLoader::load($this->private_key)->getPublicKey()->toString('OpenSSH',['comment' => '']);
} catch (\Exception $e) { } catch (\Throwable $e) {
return 'Error loading private key'; return 'Error loading private key';
} }
} }

View File

@@ -52,7 +52,7 @@ function format_docker_envs_to_json($rawOutput)
$env = explode('=', $env); $env = explode('=', $env);
return [$env[0] => $env[1]]; return [$env[0] => $env[1]];
}); });
} catch (\Throwable $th) { } catch (\Throwable $e) {
return collect([]); return collect([]);
} }
} }

View File

@@ -203,7 +203,7 @@ function validateServer(Server $server)
"uptime" => $uptime, "uptime" => $uptime,
"dockerVersion" => $dockerVersion, "dockerVersion" => $dockerVersion,
]; ];
} catch (\Exception $e) { } catch (\Throwable $e) {
$server->settings->is_reachable = false; $server->settings->is_reachable = false;
$server->settings->is_usable = false; $server->settings->is_usable = false;
throw $e; throw $e;
@@ -219,7 +219,7 @@ function check_server_connection(Server $server)
instant_remote_process(['uptime'], $server); instant_remote_process(['uptime'], $server);
$server->unreachable_count = 0; $server->unreachable_count = 0;
$server->settings->is_reachable = true; $server->settings->is_reachable = true;
} catch (\Exception $e) { } catch (\Throwable $e) {
if ($server->unreachable_count == 2) { if ($server->unreachable_count == 2) {
$server->team->notify(new NotReachable($server)); $server->team->notify(new NotReachable($server));
$server->settings->is_reachable = false; $server->settings->is_reachable = false;
@@ -246,7 +246,7 @@ function checkRequiredCommands(Server $server)
} }
try { try {
instant_remote_process(["docker run --rm --privileged --net=host --pid=host --ipc=host --volume /:/host busybox chroot /host bash -c 'apt update && apt install -y {$command}'"], $server); instant_remote_process(["docker run --rm --privileged --net=host --pid=host --ipc=host --volume /:/host busybox chroot /host bash -c 'apt update && apt install -y {$command}'"], $server);
} catch (\Exception $e) { } catch (\Throwable $e) {
ray('could not install ' . $command); ray('could not install ' . $command);
ray($e); ray($e);
break; break;

View File

@@ -89,18 +89,18 @@ function general_error_handler(Throwable | null $err = null, $that = null, $isJs
} }
throw new Exception($customErrorMessage ?? $err->getMessage()); throw new Exception($customErrorMessage ?? $err->getMessage());
} }
} catch (Throwable $error) { } catch (Throwable $e) {
if ($that) { if ($that) {
return $that->emit('error', $customErrorMessage ?? $error->getMessage()); return $that->emit('error', $customErrorMessage ?? $e->getMessage());
} elseif ($isJson) { } elseif ($isJson) {
return response()->json([ return response()->json([
'code' => $error->getCode(), 'code' => $e->getCode(),
'error' => $error->getMessage(), 'error' => $e->getMessage(),
]); ]);
} else { } else {
ray($customErrorMessage); ray($customErrorMessage);
ray($error); ray($e);
return $customErrorMessage ?? $error->getMessage(); return $customErrorMessage ?? $e->getMessage();
} }
} }
} }
@@ -116,9 +116,9 @@ function get_latest_version_of_coolify(): string
$response = Http::get('https://cdn.coollabs.io/coolify/versions.json'); $response = Http::get('https://cdn.coollabs.io/coolify/versions.json');
$versions = $response->json(); $versions = $response->json();
return data_get($versions, 'coolify.v4.version'); return data_get($versions, 'coolify.v4.version');
} catch (Throwable $th) { } catch (Throwable $e) {
//throw $th; //throw $e;
ray($th->getMessage()); ray($e->getMessage());
return '0.0.0'; return '0.0.0';
} }
} }
@@ -258,8 +258,8 @@ function send_internal_notification(string $message): void
$baseUrl = config('app.name'); $baseUrl = config('app.name');
$team = Team::find(0); $team = Team::find(0);
$team->notify(new GeneralNotification("👀 {$baseUrl}: " . $message)); $team->notify(new GeneralNotification("👀 {$baseUrl}: " . $message));
} catch (\Throwable $th) { } catch (\Throwable $e) {
ray($th->getMessage()); ray($e->getMessage());
} }
} }
function send_user_an_email(MailMessage $mail, string $email): void function send_user_an_email(MailMessage $mail, string $email): void

View File

@@ -38,7 +38,7 @@ class InstanceSettingsSeeder extends Seeder
if (is_null($settings->public_ipv6) && $ipv6) { if (is_null($settings->public_ipv6) && $ipv6) {
$settings->update(['public_ipv6' => $ipv6]); $settings->update(['public_ipv6' => $ipv6]);
} }
} catch (\Exception $e) { } catch (\Throwable $e) {
echo "Error: {$e->getMessage()}\n"; echo "Error: {$e->getMessage()}\n";
} }
} }

View File

@@ -119,7 +119,7 @@ class ProductionSeeder extends Seeder
$settings->update(['public_ipv6' => $ipv6]); $settings->update(['public_ipv6' => $ipv6]);
} }
} }
} catch (\Exception $e) { } catch (\Throwable $e) {
echo "Error: {$e->getMessage()}\n"; echo "Error: {$e->getMessage()}\n";
} }
} }