mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +00:00
Add the ability to throw exceptions in a feed update if desired
This is useful when adding a new feed
This commit is contained in:
parent
43f73b5d71
commit
7546e3b11b
1 changed files with 3 additions and 2 deletions
|
@ -421,7 +421,7 @@ class Database {
|
||||||
// Add the feed to the database and return its Id which will be used when adding
|
// Add the feed to the database and return its Id which will be used when adding
|
||||||
// its articles to the database.
|
// its articles to the database.
|
||||||
try {
|
try {
|
||||||
$this->feedUpdate($feedID);
|
$this->feedUpdate($feedID, true);
|
||||||
} catch(\Throwable $e) {
|
} catch(\Throwable $e) {
|
||||||
$this->db->prepare('DELETE from arsse_feeds where id is ?', 'int')->run($feedID);
|
$this->db->prepare('DELETE from arsse_feeds where id is ?', 'int')->run($feedID);
|
||||||
throw $e;
|
throw $e;
|
||||||
|
@ -429,7 +429,7 @@ class Database {
|
||||||
return $feedID;
|
return $feedID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function feedUpdate(int $feedID): bool {
|
public function feedUpdate(int $feedID, bool $throwError = false): bool {
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
try {
|
try {
|
||||||
// check to make sure the feed exists
|
// check to make sure the feed exists
|
||||||
|
@ -453,6 +453,7 @@ class Database {
|
||||||
'datetime', 'str', 'int'
|
'datetime', 'str', 'int'
|
||||||
)->run(Feed::nextFetchOnError($f['err_count']), $e->getMessage(),$feedID);
|
)->run(Feed::nextFetchOnError($f['err_count']), $e->getMessage(),$feedID);
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
|
if($throwError) throw $e;
|
||||||
return false;
|
return false;
|
||||||
} catch(\Throwable $e) {
|
} catch(\Throwable $e) {
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
|
|
Loading…
Reference in a new issue