aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/FeedExpander.php12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/FeedExpander.php b/lib/FeedExpander.php
index be3a8ca4..abe964e1 100644
--- a/lib/FeedExpander.php
+++ b/lib/FeedExpander.php
@@ -23,14 +23,20 @@ abstract class FeedExpander extends BridgeAbstract
throw new \Exception(sprintf('Unable to parse xml from `%s` because we got the empty string', $url), 10);
}
// prepare/massage the xml to make it more acceptable
- $badStrings = [
+ $problematicStrings = [
' ',
'»',
'’',
];
- $xmlString = str_replace($badStrings, '', $xmlString);
+ $xmlString = str_replace($problematicStrings, '', $xmlString);
+
$feedParser = new FeedParser();
- $this->feed = $feedParser->parseFeed($xmlString);
+ try {
+ $this->feed = $feedParser->parseFeed($xmlString);
+ } catch (\Exception $e) {
+ throw new \Exception(sprintf('Failed to parse xml from %s: %s', $url, create_sane_exception_message($e)));
+ }
+
$items = array_slice($this->feed['items'], 0, $maxItems);
// todo: extract parse logic out from FeedParser
foreach ($items as $item) {