summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSean Molenaar <sean@seanmolenaar.eu>2019-03-11 22:36:00 +0100
committerSean Molenaar <SMillerDev@users.noreply.github.com>2019-03-12 13:30:05 +0100
commit9d5ac4b039ecb8f0dd37ede8bc0ae771f1580903 (patch)
treef91d90b0947e1842ee18cc6d68490911ddcc1cbe /lib
parent21b75aadd57c33e70a7b443eb20c096436c0f169 (diff)
Catch FeedIO reader exception.
Closes #413 Closes #412
Diffstat (limited to 'lib')
-rw-r--r--lib/Fetcher/Fetcher.php4
-rw-r--r--lib/Fetcher/IFeedFetcher.php4
-rw-r--r--lib/Service/FeedService.php29
3 files changed, 22 insertions, 15 deletions
diff --git a/lib/Fetcher/Fetcher.php b/lib/Fetcher/Fetcher.php
index 23f5b57f7..425004680 100644
--- a/lib/Fetcher/Fetcher.php
+++ b/lib/Fetcher/Fetcher.php
@@ -13,6 +13,8 @@
namespace OCA\News\Fetcher;
+use FeedIo\Reader\ReadErrorException;
+
class Fetcher
{
@@ -48,7 +50,7 @@ class Fetcher
* @param string $user if given, basic auth is set for this feed
* @param string $password if given, basic auth is set for this feed. Ignored if user is empty
*
- * @throws FetcherException if FeedIO fails
+ * @throws ReadErrorException if FeedIO fails
* @return array an array containing the new feed and its items, first
* element being the Feed and second element being an array of Items
*/
diff --git a/lib/Fetcher/IFeedFetcher.php b/lib/Fetcher/IFeedFetcher.php
index ecc0ffc16..81bf8526f 100644
--- a/lib/Fetcher/IFeedFetcher.php
+++ b/lib/Fetcher/IFeedFetcher.php
@@ -13,6 +13,8 @@
namespace OCA\News\Fetcher;
+use FeedIo\Reader\ReadErrorException;
+
interface IFeedFetcher
{
@@ -28,7 +30,7 @@ interface IFeedFetcher
*
* @return array an array containing the new feed and its items, first
* element being the Feed and second element being an array of Items
- * @throws FetcherException if the fetcher encounters a problem
+ * @throws ReadErrorException if the Feed-IO fetcher encounters a problem
*/
public function fetch(string $url, bool $favicon, $lastModified, $user, $password): array;
diff --git a/lib/Service/FeedService.php b/lib/Service/FeedService.php
index f46171868..6dee1fd1c 100644
--- a/lib/Service/FeedService.php
+++ b/lib/Service/FeedService.php
@@ -13,6 +13,7 @@
namespace OCA\News\Service;
+use FeedIo\Reader\ReadErrorException;
use HTMLPurifier;
use OCP\ILogger;
@@ -24,7 +25,6 @@ use OCA\News\Db\Item;
use OCA\News\Db\FeedMapper;
use OCA\News\Db\ItemMapper;
use OCA\News\Fetcher\Fetcher;
-use OCA\News\Fetcher\FetcherException;
use OCA\News\Config\Config;
use OCA\News\Utility\Time;
@@ -165,7 +165,7 @@ class FeedService extends Service
$feed->setUnreadCount($unreadCount);
return $feed;
- } catch (FetcherException $ex) {
+ } catch (ReadErrorException $ex) {
$this->logger->debug($ex->getMessage(), $this->loggerParams);
throw new ServiceNotFoundException($ex->getMessage());
}
@@ -300,7 +300,7 @@ class FeedService extends Service
// mark feed as successfully updated
$existingFeed->setUpdateErrorCount(0);
$existingFeed->setLastUpdateError('');
- } catch (FetcherException $ex) {
+ } catch (ReadErrorException $ex) {
$existingFeed->setUpdateErrorCount(
$existingFeed->getUpdateErrorCount() + 1
);
@@ -456,18 +456,21 @@ class FeedService extends Service
}
/**
- * @param $feedId
- * @param $userId
- * @param $diff an array containing the fields to update, e.g.:
- * [
- * 'ordering' => 1,
- * 'fullTextEnabled' => true,
- * 'pinned' => true,
- * 'updateMode' => 0,
- * 'title' => 'title'
- * ]
+ * @param string $feedId ID of the feed.
+ * @param string $userId ID of the user.
+ * @param array $diff An array containing the fields to update, e.g.:
+ * <code>
+ * [
+ * 'ordering' => 1,
+ * 'fullTextEnabled' => true,
+ * 'pinned' => true,
+ * 'updateMode' => 0,
+ * 'title' => 'title'
+ * ]
+ * </code>
*
* @throws ServiceNotFoundException if feed does not exist
+ * @return Feed The patched feed
*/
public function patch($feedId, $userId, $diff = [])
{