From: Andrew Dolgov Date: Sun, 10 Dec 2017 06:27:07 +0000 (+0300) Subject: pdo_connect: catch exception on create X-Git-Tag: 18.8~123 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=83a052f1fa36e6bcebc6b6ee1ba6cfc9d9f480d0;p=tt-rss.git pdo_connect: catch exception on create --- diff --git a/classes/db.php b/classes/db.php index b6320944..96a88827 100644 --- a/classes/db.php +++ b/classes/db.php @@ -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 "
Exception while creating PDO object:" . $e->getMessage() . "
"; exit(101); }