From 10b7b446cfe164c384ada69a795105b1fab33e16 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Fri, 4 Sep 2026 10:44:01 +0200 Subject: [PATCH] Optimized ExecuteDbStatement error handling --- services/DatabaseService.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/services/DatabaseService.php b/services/DatabaseService.php index 414bb3c6..6e116568 100644 --- a/services/DatabaseService.php +++ b/services/DatabaseService.php @@ -36,20 +36,25 @@ class DatabaseService } } - if ($params == null) + if ($params === null) { - if ($pdo->exec($sql) === false) { - throw new \Exception($pdo->errorInfo()); + throw new \Exception(implode(' | ', $pdo->errorInfo())); } } else { $cmd = $pdo->prepare($sql); + + if ($cmd === false) + { + throw new \Exception(implode(' | ', $pdo->errorInfo())); + } + if ($cmd->execute($params) === false) { - throw new \Exception($pdo->errorInfo()); + throw new \Exception(implode(' | ', $cmd->errorInfo())); } }