enable controller based exception handling

This commit is contained in:
Daniel Seifert 2021-11-03 10:16:39 +01:00
parent 3b47f4da05
commit ae09cf88a5
Signed by: DanielS
GPG Key ID: 8A7C4C6ED1915C6F
2 changed files with 54 additions and 26 deletions

View File

@ -61,6 +61,19 @@ class d3ActionWizard extends AdminDetailsController
public function runTask()
{
try {
$this->execute();
} catch (DataWizardException|DBALException|DatabaseErrorException $e) {
Registry::getLogger()->error($e->getMessage());
Registry::getUtilsView()->addErrorToDisplay($e);
}
}
/**
* @throws DatabaseConnectionException
* @throws DatabaseErrorException
*/
protected function execute()
{
$id = Registry::getRequest()->getRequestEscapedParameter('taskid');
$action = $this->configuration->getActionById($id);
@ -74,9 +87,6 @@ class d3ActionWizard extends AdminDetailsController
}
$action->run();
} catch (DataWizardException|DBALException|DatabaseErrorException $e) {
Registry::getUtilsView()->addErrorToDisplay($e);
}
}
public function getUserMessages()

View File

@ -18,6 +18,8 @@ namespace D3\DataWizard\Application\Controller\Admin;
use D3\DataWizard\Application\Model\Configuration;
use D3\DataWizard\Application\Model\Exceptions\DataWizardException;
use D3\DataWizard\Application\Model\Exceptions\DebugException;
use D3\DataWizard\Application\Model\Exceptions\NoSuitableRendererException;
use D3\DataWizard\Application\Model\Exceptions\TaskException;
use D3\ModCfg\Application\Model\d3database;
use D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception;
use D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException;
@ -61,6 +63,25 @@ class d3ExportWizard extends AdminDetailsController
public function runTask()
{
try {
$this->execute();
} catch (DataWizardException|DBALException|DatabaseErrorException $e) {
Registry::getLogger()->error($e->getMessage());
Registry::getUtilsView()->addErrorToDisplay($e);
}
}
/**
* @throws DBALException
* @throws DatabaseConnectionException
* @throws DatabaseErrorException
* @throws StandardException
* @throws NoSuitableRendererException
* @throws TaskException
* @throws d3ShopCompatibilityAdapterException
* @throws d3_cfg_mod_exception
*/
protected function execute()
{
$id = Registry::getRequest()->getRequestEscapedParameter('taskid');
$export = $this->configuration->getExportById($id);
@ -74,9 +95,6 @@ class d3ExportWizard extends AdminDetailsController
}
$export->run(Registry::getRequest()->getRequestEscapedParameter('format'));
} catch (DataWizardException|DBALException|DatabaseErrorException $e) {
Registry::getUtilsView()->addErrorToDisplay($e);
}
}
public function getUserMessages()