no need to report last dashboard exception #yjypx2
This commit is contained in:
parent
e9e0012175
commit
d413e04813
10
app/Exceptions/Common/LastDashboard.php
Normal file
10
app/Exceptions/Common/LastDashboard.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exceptions\Common;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class LastDashboard extends Exception
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
10
app/Exceptions/Common/NotUserDashboard.php
Normal file
10
app/Exceptions/Common/NotUserDashboard.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exceptions\Common;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class NotUserDashboard extends Exception
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
@ -3,6 +3,8 @@
|
|||||||
namespace App\Jobs\Common;
|
namespace App\Jobs\Common;
|
||||||
|
|
||||||
use App\Abstracts\Job;
|
use App\Abstracts\Job;
|
||||||
|
use App\Exceptions\Common\LastDashboard;
|
||||||
|
use App\Exceptions\Common\NotUserDashboard;
|
||||||
use App\Traits\Users;
|
use App\Traits\Users;
|
||||||
|
|
||||||
class DeleteDashboard extends Job
|
class DeleteDashboard extends Job
|
||||||
@ -56,14 +58,14 @@ class DeleteDashboard extends Job
|
|||||||
|
|
||||||
$message = trans('dashboards.error.delete_last');
|
$message = trans('dashboards.error.delete_last');
|
||||||
|
|
||||||
throw new \Exception($message);
|
throw new LastDashboard($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if user can access dashboard
|
// Check if user can access dashboard
|
||||||
if ($this->isNotUserDashboard($this->dashboard->id)) {
|
if ($this->isNotUserDashboard($this->dashboard->id)) {
|
||||||
$message = trans('dashboards.error.not_user_dashboard');
|
$message = trans('dashboards.error.not_user_dashboard');
|
||||||
|
|
||||||
throw new \Exception($message);
|
throw new NotUserDashboard($message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,13 @@
|
|||||||
namespace App\Listeners\Module;
|
namespace App\Listeners\Module;
|
||||||
|
|
||||||
use App\Events\Module\Uninstalled as Event;
|
use App\Events\Module\Uninstalled as Event;
|
||||||
|
use App\Exceptions\Common\LastDashboard;
|
||||||
use App\Jobs\Common\DeleteDashboard;
|
use App\Jobs\Common\DeleteDashboard;
|
||||||
use App\Jobs\Common\DeleteReport;
|
use App\Jobs\Common\DeleteReport;
|
||||||
use App\Models\Common\Dashboard;
|
use App\Models\Common\Dashboard;
|
||||||
use App\Models\Common\Report;
|
use App\Models\Common\Report;
|
||||||
use App\Traits\Jobs;
|
use App\Traits\Jobs;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
class FinishUninstallation
|
class FinishUninstallation
|
||||||
{
|
{
|
||||||
@ -36,7 +38,11 @@ class FinishUninstallation
|
|||||||
Dashboard::alias($alias)->get()->each(function ($dashboard) {
|
Dashboard::alias($alias)->get()->each(function ($dashboard) {
|
||||||
try {
|
try {
|
||||||
$this->dispatch(new DeleteDashboard($dashboard));
|
$this->dispatch(new DeleteDashboard($dashboard));
|
||||||
} catch (\Exception | \Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
|
if ($e instanceof LastDashboard) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
report($e);
|
report($e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -53,7 +59,7 @@ class FinishUninstallation
|
|||||||
Report::alias($alias)->get()->each(function ($report) {
|
Report::alias($alias)->get()->each(function ($report) {
|
||||||
try {
|
try {
|
||||||
$this->dispatch(new DeleteReport($report));
|
$this->dispatch(new DeleteReport($report));
|
||||||
} catch (\Exception | \Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
report($e);
|
report($e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user