use Galette\Core\Install as GaletteInstall;
use Galette\Core\Db as GaletteDb;
-$db_connected = $install->testDbConnexion();
+try {
+ $db_connected = $install->testDbConnexion();
+} catch (Throwable $e) {
+ $db_connected = $e;
+}
$conndb_ok = true;
$permsdb_ok = true;
echo '<div class="ui red message">';
echo '<div class="ui small header">' . _T("Unable to connect to the database") . '</div>';
echo '<p>' . $db_connected->getMessage() . '</p>';
- echo '<pre>' . $db_connected->getTraceAsString() . '</pre>';
echo '</div>';
}
}
?>
</ul>
+ <?php
+}
+?>
</div>
</div>
</div>
- <?php
-}
+<?php
if (!isset($install_plugin)) {
?>
<form action="installer.php" method="POST" class="ui form">
* @param string $db database name
*
* @return true
+ *
+ * @throws \Exception|Throwable
*/
public static function testConnectivity(
$type,
$port = null,
$db = null
) {
- $_type = null;
try {
if ($type === self::MYSQL) {
$_type = 'Pdo_Mysql';
} elseif ($type === self::PGSQL) {
$_type = 'Pdo_Pgsql';
} else {
- throw new \Exception();
+ throw new \Exception('Unknown database type');
}
$_options = array(
/**
* Test database connection
*
- * @return true|array true if connection was successfull,
- * an array with some infos otherwise
+ * @return true
+ *
+ * @throws \Exception
*/
public function testDbConnexion()
{