From 5d6c4939f608b0e6ec4a7e4754b12c7f8219298d Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Wed, 14 Feb 2024 11:01:12 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B07245=20Bettor=20logs=20on=20RunTimeEnvir?= =?UTF-8?q?onment::CallInstallerHandlers=20exceptions=20(#606)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup/runtimeenv.class.inc.php | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/setup/runtimeenv.class.inc.php b/setup/runtimeenv.class.inc.php index f7ffc3483..3b92fa460 100644 --- a/setup/runtimeenv.class.inc.php +++ b/setup/runtimeenv.class.inc.php @@ -1079,13 +1079,14 @@ class RunTimeEnvironment SetupUtils::tidydir(APPROOT.'env-'.$this->sTargetEnv); } } - - /** - * Call the given handler method for all selected modules having an installation handler - * @param array[] $aAvailableModules - * @param string[] $aSelectedModules - * @param string $sHandlerName - */ + + /** + * Call the given handler method for all selected modules having an installation handler + * @param array[] $aAvailableModules + * @param string[] $aSelectedModules + * @param string $sHandlerName + * @throws CoreException + */ public function CallInstallerHandlers($aAvailableModules, $aSelectedModules, $sHandlerName) { foreach($aAvailableModules as $sModuleId => $aModule) @@ -1098,8 +1099,20 @@ class RunTimeEnvironment $aCallSpec = array($sModuleInstallerClass, $sHandlerName); if (is_callable($aCallSpec)) { - call_user_func_array($aCallSpec, array(MetaModel::GetConfig(), $aModule['version_db'], $aModule['version_code'])); - } + try { + call_user_func_array($aCallSpec, array(MetaModel::GetConfig(), $aModule['version_db'], $aModule['version_code'])); + } catch (Exception $e) { + $sErrorMessage = "Module $sModuleId : error when calling module installer class $sModuleInstallerClass for $sHandlerName handler"; + $aExceptionContextData = [ + 'ModulelId' => $sModuleId, + 'ModuleInstallerClass' => $sModuleInstallerClass, + 'ModuleInstallerHandler' => $sHandlerName, + 'ExceptionClass' => get_class($e), + 'ExceptionMessage' => $e->getMessage(), + ]; + throw new CoreException($sErrorMessage, $aExceptionContextData, '', $e); + } + } } } }