Skip to content

Commit

Permalink
handle artists with faulty data gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
wchristian committed Dec 4, 2011
1 parent a553b4f commit fb3e823
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion gapfinder.pl
Expand Up @@ -8,6 +8,7 @@ package gapfinder;
use Net::LastFMAPI 0.4;
use List::Util qw(sum);
use Config::INI::Reader;
use Try::Tiny;
no warnings 'once';

use Devel::Comments;
Expand Down Expand Up @@ -181,7 +182,13 @@ sub get_artist_tracks {

local $Net::LastFMAPI::cache = $config->{_}{cache_artist_data};

my @tracks = all_rows( "artist.getTopTracks", artist => $artist );
my @tracks = try {
all_rows( "artist.getTopTracks", artist => $artist ) ;
}
catch {
push @{$errors}, "Encountered error for '$artist': $_";
return;
};

if ( !@tracks ) {
push @{$errors}, "Artist '$artist' has no tracks.";
Expand Down

0 comments on commit fb3e823

Please sign in to comment.