]> git.wh0rd.org - tt-rss.git/commitdiff
pdo_connect: catch exception on create
authorAndrew Dolgov <noreply@fakecake.org>
Sun, 10 Dec 2017 06:27:07 +0000 (09:27 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Sun, 10 Dec 2017 06:27:07 +0000 (09:27 +0300)
classes/db.php

index b6320944b549ff3be1d58a876060af1ae69f98c9..96a8882751078adb63d72e7ac623d9e2a87ea741 100644 (file)
@@ -54,12 +54,12 @@ class Db
                $db_port = defined('DB_PORT') && DB_PORT ? ';port=' . DB_PORT : '';
                $db_host = defined('DB_HOST') && DB_HOST ? ';host=' . DB_HOST : '';
 
-               $this->pdo = new PDO(DB_TYPE . ':dbname=' . DB_NAME . $db_host . $db_port,
-                       DB_USER,
-                       DB_PASS);
-
-               if (!$this->pdo) {
-                       print("Error connecting via PDO.");
+               try {
+                       $this->pdo = new PDO(DB_TYPE . ':dbname=' . DB_NAME . $db_host . $db_port,
+                               DB_USER,
+                               DB_PASS);
+               } catch (Exception $e) {
+                       print "<pre>Exception while creating PDO object:" . $e->getMessage() . "</pre>";
                        exit(101);
                }