From 6896e620bafd2620205209bba1b5dfefb174b72b Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Wed, 12 May 2021 23:12:00 +0200 Subject: [PATCH] Tolerate errors in Atom feeds --- lib/Rss2Html/Feed.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Rss2Html/Feed.pm b/lib/Rss2Html/Feed.pm index b7292a5..2dfee43 100644 --- a/lib/Rss2Html/Feed.pm +++ b/lib/Rss2Html/Feed.pm @@ -17,6 +17,7 @@ use strict; use warnings; use v5.14; use Moose; +use Try::Tiny; use Cache::Memcached; use Encode qw(decode_utf8); @@ -128,7 +129,13 @@ sub update { } } elsif ($self->{type} eq 'atom') { my $api = XML::Atom::Client->new(); - my $atomfeed = $api->getFeed($self->{url}); + my $atomfeed; + try { + # This doesn't work. XML::Atom::Client EXITS on error! + $atomfeed = $api->getFeed($self->{url}); + } catch { + $self->log->error("error fetching $self->{url}: $@"); + } if ($atomfeed) { my @items = $atomfeed->entries; for my $item (@items) {