From 9f7eba4cf861760b3b25213bc199ebaaf731f665 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Mon, 30 May 2022 10:20:08 +0200 Subject: [PATCH] WelcomeForm: Don't raise sys errors directly but use notifications to notify the user --- application/forms/Dashboard/DashletForm.php | 4 ++-- application/forms/Dashboard/WelcomeForm.php | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/application/forms/Dashboard/DashletForm.php b/application/forms/Dashboard/DashletForm.php index fc4024ffc..c10901e63 100644 --- a/application/forms/Dashboard/DashletForm.php +++ b/application/forms/Dashboard/DashletForm.php @@ -26,13 +26,13 @@ class DashletForm extends SetupNewDashboardForm public function load(BaseDashboard $dashboard) { /** @var Dashlet $dashboard */ - $this->populate(array( + $this->populate([ 'org_home' => $this->requestUrl->getParam('home'), 'org_pane' => $dashboard->getPane()->getName(), 'org_dashlet' => $dashboard->getName(), 'dashlet' => $dashboard->getTitle(), 'url' => $dashboard->getUrl()->getRelativeUrl() - )); + ]); } protected function assembleNextPageDashboardPart() diff --git a/application/forms/Dashboard/WelcomeForm.php b/application/forms/Dashboard/WelcomeForm.php index 3b40b5857..ee3bcf58f 100644 --- a/application/forms/Dashboard/WelcomeForm.php +++ b/application/forms/Dashboard/WelcomeForm.php @@ -4,10 +4,12 @@ namespace Icinga\Forms\Dashboard; +use Icinga\Application\Logger; use Icinga\Application\Modules; use Icinga\Web\Dashboard\Dashboard; use Icinga\Web\Dashboard\DashboardHome; use Icinga\Util\DBUtils; +use Icinga\Web\Notification; use ipl\Html\Form; use ipl\Web\Url; @@ -64,8 +66,15 @@ class WelcomeForm extends Form $conn->commitTransaction(); } catch (\Exception $err) { $conn->rollBackTransaction(); - throw $err; + + Logger::error('Unable to apply the system defaults into the DB. An error occurred: %s', $err); + + Notification::error(t('Failed to successfully save the data. Please check the logs for details.')); + + return; } + + Notification::success(t('Imported system defaults successfully.')); } } }