Browse files

an empty response is an unrecoverable error. later on ...

... this could be worked around by degrading the limit of the pagination
so we can skip the faulty piece of data and still retrieve everything else.
This will need some clever coding because it'll likely need to degrade down
to 1 and then have to be upgraded again afterwards, but without
encountering the faulty bit again
  • Loading branch information...
1 parent e8f95bc commit 00baba207aa9dc1bfe86b994f6a80dd84012ae35 @wchristian wchristian committed Dec 4, 2011
Showing with 4 additions and 0 deletions.
  1. +4 −0 lib/Net/LastFMAPI.pm
View
4 lib/Net/LastFMAPI.pm
@@ -262,6 +262,10 @@ sub lastfm {
$params{format} ||= "xml";
my $content = $res->decoded_content;
+ croak "Last.fm contains faulty data for a piece of data you requested and "
+ . "is unable to return a useful reply. Will be treated as an empty reply."
+ if $content eq qq|""\n|;
+
my $decoded_json = sub { $content = decode_json($content); };
unless ($res->is_success &&
($params{format} eq "json" && !exists($decoded_json->()->{error})

0 comments on commit 00baba2

Please sign in to comment.