error handling

This commit is contained in:
Roland Gruber 2020-04-27 21:53:50 +02:00
parent 8d50dd59b0
commit 7fcc2cf38d
2 changed files with 9 additions and 2 deletions

View File

@ -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));
}
}

View File

@ -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);
}
}
}