diff --git a/lang/de_de.php b/lang/de_de.php
index d2e5a39ab..32f0503a6 100644
--- a/lang/de_de.php
+++ b/lang/de_de.php
@@ -57,6 +57,8 @@ protected function _LoadStrings()
$strings['Error'] = 'Fehler';
$strings['ReturnToPreviousPage'] = 'Zurück zur vorigen Seite';
$strings['UnknownError'] = 'Unbekannter Fehler';
+ $strings['DatabaseConnectionError'] = 'Verbindung zum Datenbankserver konnte nicht hergestellt werden.
Bitten Sie den Website-Administrator, Host, Benutzername und Passwort der Datenbank in config/config.php zu prüfen.';
+ $strings['DatabaseNotFoundError'] = 'Die konfigurierte Datenbank konnte nicht ausgewählt werden.
Bitten Sie den Website-Administrator, den Datenbanknamen in config/config.php zu prüfen und zu bestätigen, dass die Datenbank erstellt/initialisiert wurde.';
$strings['InsufficientPermissionsError'] = 'Sie haben keinen Zugriff auf diese Ressource.';
$strings['MissingReservationResourceError'] = 'Keine Ressource ausgewählt';
$strings['MissingReservationScheduleError'] = 'Kein Terminplan ausgewählt';
diff --git a/lang/en_us.php b/lang/en_us.php
index d7fb85d4e..50fc1b51a 100644
--- a/lang/en_us.php
+++ b/lang/en_us.php
@@ -94,6 +94,8 @@ protected function _LoadStrings()
$strings['Error'] = 'Error';
$strings['ReturnToPreviousPage'] = 'Return to the last page that you were on';
$strings['UnknownError'] = 'Unknown Error';
+ $strings['DatabaseConnectionError'] = 'Unable to connect to the database server.
Ask the website administrator to verify the database host, username, and password in config/config.php.';
+ $strings['DatabaseNotFoundError'] = 'Unable to select the configured database.
Ask the website administrator to verify the database name in config/config.php and confirm the database has been created/initialized.';
$strings['InsufficientPermissionsError'] = 'You do not have permission to access this resource';
$strings['MissingReservationResourceError'] = 'A resource was not selected';
$strings['MissingReservationScheduleError'] = 'A schedule was not selected';
diff --git a/lang/es.php b/lang/es.php
index a56efe539..219f22ea2 100644
--- a/lang/es.php
+++ b/lang/es.php
@@ -59,6 +59,8 @@ protected function _LoadStrings()
$strings['Error'] = 'Error';
$strings['ReturnToPreviousPage'] = 'Volver a la página anterior';
$strings['UnknownError'] = 'Error desconocido';
+ $strings['DatabaseConnectionError'] = 'No se pudo conectar al servidor de base de datos.
Pide al administrador del sitio web que verifique el host, usuario y contraseña de la base de datos en config/config.php.';
+ $strings['DatabaseNotFoundError'] = 'No se pudo seleccionar la base de datos configurada.
Pide al administrador del sitio web que verifique el nombre de la base de datos en config/config.php y confirme que la base de datos ha sido creada/inicializada.';
$strings['InsufficientPermissionsError'] = 'No tienes permiso para acceder a este recurso';
$strings['MissingReservationResourceError'] = 'No se ha seleccionado un recurso';
$strings['MissingReservationScheduleError'] = 'No se ha seleccionado una planificación';
diff --git a/lang/ja_jp.php b/lang/ja_jp.php
index 8e43a598b..1e36d013b 100644
--- a/lang/ja_jp.php
+++ b/lang/ja_jp.php
@@ -95,6 +95,8 @@ protected function _LoadStrings()
$strings['Error'] = 'エラー';
$strings['ReturnToPreviousPage'] = '直近のページへ戻る';
$strings['UnknownError'] = '不明なエラー';
+ $strings['DatabaseConnectionError'] = 'データベースサーバーに接続できませんでした。
Webサイト管理者に、config/config.php のデータベースのホスト名・ユーザー名・パスワード設定を確認するよう依頼してください。';
+ $strings['DatabaseNotFoundError'] = '設定されたデータベースを選択できませんでした。
Webサイト管理者に、config/config.php のデータベース名を確認し、データベースが作成/初期化済みであることを確認するよう依頼してください。';
$strings['InsufficientPermissionsError'] = 'このリソースを操作する権限がありません';
$strings['MissingReservationResourceError'] = 'リソースが選択されていません';
$strings['MissingReservationScheduleError'] = 'スケジュールが選択されていません';
diff --git a/lib/Common/ErrorMessages.php b/lib/Common/ErrorMessages.php
index 2681d1803..6eff6885c 100644
--- a/lib/Common/ErrorMessages.php
+++ b/lib/Common/ErrorMessages.php
@@ -8,6 +8,8 @@ class ErrorMessages
public const MISSING_SCHEDULE = 3;
public const RESERVATION_NOT_FOUND = 4;
public const RESERVATION_NOT_AVAILABLE = 5;
+ public const DATABASE_CONNECTION = 6;
+ public const DATABASE_NOT_FOUND = 7;
private $_resourceKeys = [];
private static $_instance;
@@ -19,6 +21,8 @@ private function __construct()
$this->SetKey(ErrorMessages::MISSING_SCHEDULE, 'MissingReservationScheduleError');
$this->SetKey(ErrorMessages::RESERVATION_NOT_FOUND, 'ReservationNotFoundError');
$this->SetKey(ErrorMessages::RESERVATION_NOT_AVAILABLE, 'ReservationNotAvailable');
+ $this->SetKey(ErrorMessages::DATABASE_CONNECTION, 'DatabaseConnectionError');
+ $this->SetKey(ErrorMessages::DATABASE_NOT_FOUND, 'DatabaseNotFoundError');
}
/**
diff --git a/lib/Common/Logging/ExceptionHandler.php b/lib/Common/Logging/ExceptionHandler.php
index a70f18d83..3abfff0cd 100644
--- a/lib/Common/Logging/ExceptionHandler.php
+++ b/lib/Common/Logging/ExceptionHandler.php
@@ -42,7 +42,14 @@ public function HandleException($exception)
ob_start();
debug_print_backtrace();
error_log(ob_get_clean());
- call_user_func($this->callback);
+ $errorMessageId = ErrorMessages::UNKNOWN_ERROR;
+ if (is_a($exception, 'DatabaseConnectionException')) {
+ $errorMessageId = ErrorMessages::DATABASE_CONNECTION;
+ } elseif (is_a($exception, 'DatabaseNotFoundException')) {
+ $errorMessageId = ErrorMessages::DATABASE_NOT_FOUND;
+ }
+
+ call_user_func($this->callback, $errorMessageId);
}
}
diff --git a/lib/Database/DatabaseExceptions.php b/lib/Database/DatabaseExceptions.php
new file mode 100644
index 000000000..024748ae9
--- /dev/null
+++ b/lib/Database/DatabaseExceptions.php
@@ -0,0 +1,13 @@
+_db) {
$connectError = mysqli_connect_error();
Log::Error("Error connecting to database\nCheck your database settings in the config file\n%s", $connectError);
- throw new Exception("Error connecting to database\nError: " . $connectError);
+ throw new DatabaseConnectionException("Error connecting to database\nError: " . $connectError);
}
$selected = mysqli_select_db($this->_db, $this->_dbName);
if (!$selected) {
Log::Error("Error selecting database '%s'\nCheck your database settings in the config file\n%s", $this->_dbName, mysqli_error($this->_db));
- throw new Exception("Error selecting database\nError: " . mysqli_error($this->_db));
+ throw new DatabaseNotFoundException("Error selecting database\nError: " . mysqli_error($this->_db));
}
mysqli_set_charset($this->_db, 'utf8mb4');
diff --git a/lib/Database/namespace.php b/lib/Database/namespace.php
index 0c468e55c..323d88f3d 100644
--- a/lib/Database/namespace.php
+++ b/lib/Database/namespace.php
@@ -5,6 +5,7 @@
require_once(ROOT_DIR . 'lib/Database/IReader.php');
require_once(ROOT_DIR . 'lib/Database/Parameter.php');
require_once(ROOT_DIR . 'lib/Database/Parameters.php');
+require_once(ROOT_DIR . 'lib/Database/DatabaseExceptions.php');
require_once(ROOT_DIR . 'lib/Database/SqlCommand.php');
require_once(ROOT_DIR . 'lib/Database/Database.php');
require_once(ROOT_DIR . 'lib/Database/DatabaseFactory.php');