From d413e04813dfb9290a1e82c2278ea8ef41ac288a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Duli=C3=A7i?= Date: Thu, 26 Aug 2021 01:55:30 +0300 Subject: [PATCH] no need to report last dashboard exception #yjypx2 --- app/Exceptions/Common/LastDashboard.php | 10 ++++++++++ app/Exceptions/Common/NotUserDashboard.php | 10 ++++++++++ app/Jobs/Common/DeleteDashboard.php | 6 ++++-- app/Listeners/Module/FinishUninstallation.php | 10 ++++++++-- 4 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 app/Exceptions/Common/LastDashboard.php create mode 100644 app/Exceptions/Common/NotUserDashboard.php diff --git a/app/Exceptions/Common/LastDashboard.php b/app/Exceptions/Common/LastDashboard.php new file mode 100644 index 000000000..550fe05e3 --- /dev/null +++ b/app/Exceptions/Common/LastDashboard.php @@ -0,0 +1,10 @@ +isNotUserDashboard($this->dashboard->id)) { $message = trans('dashboards.error.not_user_dashboard'); - throw new \Exception($message); + throw new NotUserDashboard($message); } } } diff --git a/app/Listeners/Module/FinishUninstallation.php b/app/Listeners/Module/FinishUninstallation.php index 73785c830..c7e43dd53 100644 --- a/app/Listeners/Module/FinishUninstallation.php +++ b/app/Listeners/Module/FinishUninstallation.php @@ -3,11 +3,13 @@ namespace App\Listeners\Module; use App\Events\Module\Uninstalled as Event; +use App\Exceptions\Common\LastDashboard; use App\Jobs\Common\DeleteDashboard; use App\Jobs\Common\DeleteReport; use App\Models\Common\Dashboard; use App\Models\Common\Report; use App\Traits\Jobs; +use Throwable; class FinishUninstallation { @@ -36,7 +38,11 @@ class FinishUninstallation Dashboard::alias($alias)->get()->each(function ($dashboard) { try { $this->dispatch(new DeleteDashboard($dashboard)); - } catch (\Exception | \Throwable $e) { + } catch (Throwable $e) { + if ($e instanceof LastDashboard) { + return; + } + report($e); } }); @@ -53,7 +59,7 @@ class FinishUninstallation Report::alias($alias)->get()->each(function ($report) { try { $this->dispatch(new DeleteReport($report)); - } catch (\Exception | \Throwable $e) { + } catch (Throwable $e) { report($e); } });