diff options
Diffstat (limited to 'lib/Crawl/Bot/Plugin')
-rw-r--r-- | lib/Crawl/Bot/Plugin/Wiki.pm | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/Crawl/Bot/Plugin/Wiki.pm b/lib/Crawl/Bot/Plugin/Wiki.pm index 44765d5..66394c2 100644 --- a/lib/Crawl/Bot/Plugin/Wiki.pm +++ b/lib/Crawl/Bot/Plugin/Wiki.pm @@ -3,6 +3,7 @@ use Moose; extends 'Crawl::Bot::Plugin'; use XML::RPC; +use Try::Tiny; has xmlrpc_location => ( is => 'ro', @@ -31,16 +32,17 @@ sub tick { my $xmlrpc = XML::RPC->new($self->xmlrpc_location); warn "Getting recent wiki changes..."; - my $changes = $xmlrpc->call('wiki.getRecentChanges', $last_checked); + my $changes = try { $xmlrpc->call('wiki.getRecentChanges', $last_checked) } catch { warn $_ }; # ->call returns a hashref with error info on failure return unless ref($changes) eq 'ARRAY'; for my $change (@$changes) { warn "Page $change->{name} changed"; - my $history = $xmlrpc->call('wiki.getPageVersions', $change->{name}, 0); - next if @$history; + my $history = try { $xmlrpc->call('wiki.getPageVersions', $change->{name}, 0) } catch { warn $_ }; + next if !defined($history) || @$history; warn "Page $change->{name} is new!"; my $name = $change->{name}; - my $page = $xmlrpc->call('wiki.getPage', $change->{name}); + my $page = try { $xmlrpc->call('wiki.getPage', $change->{name}) } catch { warn $_ }; + next unless $page; if ($page =~ /(===?=?=?=?) (.*) \1/) { $name = $2; } |