diff --git a/application/startup.inc.php b/application/startup.inc.php index 8f9ea4dd5..0454e7f63 100644 --- a/application/startup.inc.php +++ b/application/startup.inc.php @@ -91,4 +91,10 @@ else $_SESSION['itop_env'] = ITOP_DEFAULT_ENV; } $sConfigFile = APPCONF.$sEnv.'/'.ITOP_CONFIG_FILE; -MetaModel::Startup($sConfigFile, false /* $bModelOnly */, $bAllowCache, false /* $bTraceSourceFiles */, $sEnv); +try { + MetaModel::Startup($sConfigFile, false /* $bModelOnly */, $bAllowCache, false /* $bTraceSourceFiles */, $sEnv); +} +catch (MySQLException $e) { + IssueLog::Debug($e->getMessage()); + throw new MySQLException('Could not connect to the DB server', []); +} \ No newline at end of file diff --git a/core/counter.class.inc.php b/core/counter.class.inc.php index eeddc4249..e7fc88985 100644 --- a/core/counter.class.inc.php +++ b/core/counter.class.inc.php @@ -188,8 +188,8 @@ final class ItopCounter if (!$hDBLink) { - throw new Exception("Could not connect to the DB server (host=$sDBHost, user=$sDBUser): ".mysqli_connect_error().' (mysql errno: '.mysqli_connect_errno().')'); - } + throw new MySQLException('Could not connect to the DB server '.mysqli_connect_error().' (mysql errno: '.mysqli_connect_errno(), array('host' => $sDBHost, 'user' => $sDBUser)); + } return $hDBLink; } diff --git a/core/mutex.class.inc.php b/core/mutex.class.inc.php index f9580a963..bd6c54d18 100644 --- a/core/mutex.class.inc.php +++ b/core/mutex.class.inc.php @@ -257,7 +257,7 @@ class iTopMutex $this->hDBLink = CMDBSource::GetMysqliInstance($sServer, $sUser, $sPwd, $sSource, $bTlsEnabled, $sTlsCA, false); if (!$this->hDBLink) { - throw new Exception("Could not connect to the DB server (host=$sServer, user=$sUser): ".mysqli_connect_error().' (mysql errno: '.mysqli_connect_errno().')'); + throw new MySQLException('Could not connect to the DB server '.mysqli_connect_error().' (mysql errno: '.mysqli_connect_errno(), array('host' => $sDBHost, 'user' => $sDBUser)); } // Make sure that the server variable `wait_timeout` is at least 86400 seconds for this connection, diff --git a/setup/backup.class.inc.php b/setup/backup.class.inc.php index edb429961..a7bb9ac70 100644 --- a/setup/backup.class.inc.php +++ b/setup/backup.class.inc.php @@ -417,8 +417,8 @@ EOF; if ($oMysqli->connect_errno) { $sHost = is_null($this->iDBPort) ? $this->sDBHost : $this->sDBHost.' on port '.$this->iDBPort; - throw new BackupException("Cannot connect to the MySQL server '$sHost' (".$oMysqli->connect_errno.") ".$oMysqli->connect_error); - } + throw new MySQLException('Could not connect to the DB server '.$oMysqli->connect_errno.' (mysql errno: '.$oMysqli->connect_error, array('host' => $sHost, 'user' => $sUser)); + } if (!$oMysqli->select_db($this->sDBName)) { throw new BackupException("The database '$this->sDBName' does not seem to exist");