Tolerate errors in Atom feeds

This commit is contained in:
Peter J. Holzer 2021-05-12 23:12:00 +02:00
parent ddceb20126
commit 6896e620ba
1 changed files with 8 additions and 1 deletions

View File

@ -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) {