From 9e0ac8876d39e9df4578499cf4766f4bc73829d1 Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Mon, 31 Oct 2022 10:15:10 +0000
Subject: [PATCH] show exception on database connection error in development
 mode, fixes #1716

Closes #1716

Merge request studip/studip!1121
---
 lib/bootstrap.php | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib/bootstrap.php b/lib/bootstrap.php
index 38b5ba65d73..21b7edcc167 100644
--- a/lib/bootstrap.php
+++ b/lib/bootstrap.php
@@ -147,9 +147,13 @@ try {
             $GLOBALS['DB_STUDIP_USER'],
             $GLOBALS['DB_STUDIP_PASSWORD']);
 } catch (PDOException $exception) {
-    header('HTTP/1.1 500 Internal Server Error');
-    die(sprintf('database connection %s failed', 'mysql:host=' . $GLOBALS['DB_STUDIP_HOST'] .
-    ';dbname=' . $GLOBALS['DB_STUDIP_DATABASE']));
+    if (Studip\ENV === 'development') {
+        throw $exception;
+    } else {
+        header('HTTP/1.1 500 Internal Server Error');
+        die(sprintf('database connection %s failed', 'mysql:host=' . $GLOBALS['DB_STUDIP_HOST'] .
+            ';dbname=' . $GLOBALS['DB_STUDIP_DATABASE']));
+    }
 }
 // set slave connection
 if (isset($GLOBALS['DB_STUDIP_SLAVE_HOST'])) {
-- 
GitLab