From 04eb93cf271f9c4edff78850381360f717de250d Mon Sep 17 00:00:00 2001 From: yggverse Date: Thu, 27 Jun 2024 17:25:06 +0300 Subject: [PATCH] remove exception logic from model --- src/Model/Database.php | 69 +++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 41 deletions(-) diff --git a/src/Model/Database.php b/src/Model/Database.php index 56e7d217..cf2b3095 100644 --- a/src/Model/Database.php +++ b/src/Model/Database.php @@ -13,47 +13,34 @@ class Database ?string $username = null, ?string $password = null ) { - try - { - $this->_database = new \PDO( - sprintf( - 'sqlite:%s', - $database - ), - $username, - $password - ); - - $this->_database->setAttribute( - \PDO::ATTR_ERRMODE, - \PDO::ERRMODE_EXCEPTION - ); - - $this->_database->setAttribute( - \PDO::ATTR_DEFAULT_FETCH_MODE, - \PDO::FETCH_OBJ - ); - - $this->_database->query(' - CREATE TABLE IF NOT EXISTS "history" - ( - "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, - "time" INTEGER NOT NULL, - "url" VARCHAR(1024) NOT NULL, - "title" VARCHAR(255) - ) - '); - } - - catch (\PDOException $exception) - { - exit( - print_r( - $exception->getMessage(), - true - ) - ); - } + $this->_database = new \PDO( + sprintf( + 'sqlite:%s', + $database + ), + $username, + $password + ); + + $this->_database->setAttribute( + \PDO::ATTR_ERRMODE, + \PDO::ERRMODE_EXCEPTION + ); + + $this->_database->setAttribute( + \PDO::ATTR_DEFAULT_FETCH_MODE, + \PDO::FETCH_OBJ + ); + + $this->_database->query(' + CREATE TABLE IF NOT EXISTS "history" + ( + "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + "time" INTEGER NOT NULL, + "url" VARCHAR(1024) NOT NULL, + "title" VARCHAR(255) + ) + '); } public function addHistory(