From 8f963adbd4727919f5d60a5ab3540c19b2c1bde2 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 20 Nov 2023 10:32:06 +0100 Subject: [PATCH] fix: only report nonruntime errors --- app/Exceptions/Handler.php | 6 +- app/Http/Livewire/Dashboard.php | 1 - app/Jobs/ApplicationDeploymentJob.php | 1 - bootstrap/helpers/shared.php | 61 ++++--------------- config/sentry.php | 4 +- config/version.php | 2 +- .../views/livewire/server/form.blade.php | 2 +- versions.json | 2 +- 8 files changed, 22 insertions(+), 57 deletions(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index b4f63661c..e78849a07 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -6,6 +6,7 @@ use App\Models\User; use Illuminate\Auth\AuthenticationException; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; +use RuntimeException; use Sentry\Laravel\Integration; use Sentry\State\Scope; use Throwable; @@ -55,7 +56,9 @@ public function register(): void { $this->reportable(function (Throwable $e) { if (isDev()) { - ray($e); + // return; + } + if ($e instanceof RuntimeException) { return; } $this->settings = InstanceSettings::get(); @@ -74,6 +77,7 @@ function (Scope $scope) { ); } ); + ray('reporting to sentry'); Integration::captureUnhandledException($e); }); } diff --git a/app/Http/Livewire/Dashboard.php b/app/Http/Livewire/Dashboard.php index 723b00f7f..b7219864d 100644 --- a/app/Http/Livewire/Dashboard.php +++ b/app/Http/Livewire/Dashboard.php @@ -3,7 +3,6 @@ namespace App\Http\Livewire; use App\Models\Project; -use App\Models\S3Storage; use App\Models\Server; use Livewire\Component; diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index dacdbf89b..32f92aefd 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -218,7 +218,6 @@ public function handle(): void $this->next(ApplicationDeploymentStatus::FINISHED->value); $this->application->isConfigurationChanged(true); } catch (Exception $e) { - ray($e); $this->fail($e); throw $e; } finally { diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 6e3c6ca4f..1953f554d 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -93,65 +93,28 @@ function refreshSession(?Team $team = null): void } function handleError(?Throwable $error = null, ?Livewire\Component $livewire = null, ?string $customErrorMessage = null) { - ray('handleError'); - ray($error); - if ($error instanceof Throwable) { - $message = $error->getMessage(); - } else { - $message = null; - } - if ($customErrorMessage) { - $message = $customErrorMessage . ' ' . $message; - } if ($error instanceof TooManyRequestsException) { if (isset($livewire)) { return $livewire->emit('error', "Too many requests. Please try again in {$error->secondsUntilAvailable} seconds."); } return "Too many requests. Please try again in {$error->secondsUntilAvailable} seconds."; } + + if ($error instanceof Throwable) { + $message = $error->getMessage(); + } else { + $message = null; + } + if ($customErrorMessage) { + $error->message = $customErrorMessage . ' ' . $message; + $message = $customErrorMessage . ' ' . $message; + } + if (isset($livewire)) { return $livewire->emit('error', $message); } - - throw new RuntimeException($message); + throw $error; } -function general_error_handler(Throwable $err, Livewire\Component $that = null, $isJson = false, $customErrorMessage = null): mixed -{ - try { - ray($err); - ray('ERROR OCCURRED: ' . $err->getMessage()); - if ($err instanceof QueryException) { - if ($err->errorInfo[0] === '23505') { - throw new Exception($customErrorMessage ?? 'Duplicate entry found.', '23505'); - } else if (count($err->errorInfo) === 4) { - throw new Exception($customErrorMessage ?? $err->errorInfo[3]); - } else { - throw new Exception($customErrorMessage ?? $err->errorInfo[2]); - } - } elseif ($err instanceof TooManyRequestsException) { - throw new Exception($customErrorMessage ?? "Too many requests. Please try again in {$err->secondsUntilAvailable} seconds."); - } else { - if ($err->getMessage() === 'This action is unauthorized.') { - return redirect()->route('dashboard')->with('error', $customErrorMessage ?? $err->getMessage()); - } - throw new Exception($customErrorMessage ?? $err->getMessage()); - } - } catch (\Throwable $e) { - if ($that) { - return $that->emit('error', $customErrorMessage ?? $e->getMessage()); - } elseif ($isJson) { - return response()->json([ - 'code' => $e->getCode(), - 'error' => $e->getMessage(), - ]); - } else { - ray($customErrorMessage); - ray($e); - return $customErrorMessage ?? $e->getMessage(); - } - } -} - function get_route_parameters(): array { return Route::current()->parameters(); diff --git a/config/sentry.php b/config/sentry.php index 2d3302d48..38c7355e9 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -3,11 +3,11 @@ return [ // @see https://docs.sentry.io/product/sentry-basics/dsn-explainer/ - 'dsn' => 'https://c35fe90ee56e18b220bb55e8217d4839@o1082494.ingest.sentry.io/4505347448045568', + 'dsn' => 'https://396748153b19c469f5ceff50f1664323@o1082494.ingest.sentry.io/4505347448045568', // The release version of your application // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) - 'release' => '4.0.0-beta.145', + 'release' => '4.0.0-beta.146', // When left empty or `null` the Laravel environment will be used 'environment' => config('app.env'), diff --git a/config/version.php b/config/version.php index 9bbb31a9f..8c257643a 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ +

You could lost a lot of functionalities if you change the server details of the server where Coolify is diff --git a/versions.json b/versions.json index d2bd0be29..905876d7a 100644 --- a/versions.json +++ b/versions.json @@ -4,7 +4,7 @@ "version": "3.12.36" }, "v4": { - "version": "4.0.0-beta.145" + "version": "4.0.0-beta.146" } } }