From 7fcc2cf38dba3f89acc2c446d0e654ca0659f383 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Mon, 27 Apr 2020 21:53:50 +0200 Subject: [PATCH] error handling --- lam/lib/persistence.inc | 9 ++++++++- lam/templates/config/confImportExport.php | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lam/lib/persistence.inc b/lam/lib/persistence.inc index a5321862..9acd66ab 100644 --- a/lam/lib/persistence.inc +++ b/lam/lib/persistence.inc @@ -208,6 +208,7 @@ class ConfigDataImporter { * @throws LAMException error during import */ private function importServerProfiles($step) { + $failedProfiles = array(); foreach ($step->getSubSteps() as $profileStep) { if (!$profileStep->isActive()) { continue; @@ -216,7 +217,13 @@ class ConfigDataImporter { $profileName = str_replace('serverProfile_', '', $profileStep->getKey()); $serverProfile = new LAMConfig($profileName); $serverProfile->importData($data); - $serverProfile->save(); + $result = $serverProfile->save(); + if ($result === LAMConfig::SAVE_FAIL) { + $failedProfiles[] = $profileName; + } + } + if (!empty($failedProfiles)) { + throw new LAMException(_('Unable to save server profile.'), implode(', ', $failedProfiles)); } } diff --git a/lam/templates/config/confImportExport.php b/lam/templates/config/confImportExport.php index 90ff6484..7a6f214b 100644 --- a/lam/templates/config/confImportExport.php +++ b/lam/templates/config/confImportExport.php @@ -261,7 +261,7 @@ printHeaderContents(_("Import and export configuration"), '../..'); } catch (LAMException $e) { $content->add(new htmlStatusMessage('ERROR', $e->getTitle(), $e->getMessage()), 12); - $content->add(new htmlButton('importCancel', _('Cancel')), 12); + $content->add(new htmlButton('importCancel', _('Back')), 12); } } }