From 7546e3b11bf7f9dfc7832c7e706ce13ceb126e53 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Sun, 30 Apr 2017 18:36:31 -0400 Subject: [PATCH] Add the ability to throw exceptions in a feed update if desired This is useful when adding a new feed --- lib/Database.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Database.php b/lib/Database.php index 62fc794..b811fa2 100644 --- a/lib/Database.php +++ b/lib/Database.php @@ -421,7 +421,7 @@ class Database { // Add the feed to the database and return its Id which will be used when adding // its articles to the database. try { - $this->feedUpdate($feedID); + $this->feedUpdate($feedID, true); } catch(\Throwable $e) { $this->db->prepare('DELETE from arsse_feeds where id is ?', 'int')->run($feedID); throw $e; @@ -429,7 +429,7 @@ class Database { return $feedID; } - public function feedUpdate(int $feedID): bool { + public function feedUpdate(int $feedID, bool $throwError = false): bool { $this->db->begin(); try { // check to make sure the feed exists @@ -453,6 +453,7 @@ class Database { 'datetime', 'str', 'int' )->run(Feed::nextFetchOnError($f['err_count']), $e->getMessage(),$feedID); $this->db->commit(); + if($throwError) throw $e; return false; } catch(\Throwable $e) { $this->db->rollback();