From 6b7e714b59e28bc138681662006941274c3261af Mon Sep 17 00:00:00 2001
From: Jonas Kohl
Date: Mon, 16 Sep 2024 19:32:09 +0200
Subject: A lot more stuff

---
 src/application/mystic/forum/Database.php | 7 +++++++
 1 file changed, 7 insertions(+)

(limited to 'src/application/mystic/forum')

diff --git a/src/application/mystic/forum/Database.php b/src/application/mystic/forum/Database.php
index 6d633fa..a1e67ea 100644
--- a/src/application/mystic/forum/Database.php
+++ b/src/application/mystic/forum/Database.php
@@ -47,13 +47,20 @@ class Database {
         return $buf;
     }
 
+    private static function exception_error_handler($errno, $errstr, $errfile, $errline ) {
+        throw new \ErrorException(html_entity_decode($errstr), $errno, 0, $errfile, $errline);
+    }
+
     public function __construct(string $connectionString) {
         try {
+            set_error_handler(self::exception_error_handler(...));
             $conn = \pg_connect($connectionString);
             if ($conn !== false)
                 $this->connection = $conn;
         } catch (\ErrorException $ex) {
             throw new DatabaseConnectionException($ex->getMessage(), $ex->getCode(), $ex);
+        } finally {
+            restore_error_handler();
         }
     }
 
-- 
cgit v1.2.3