From 003db36ba6a6e8a5817f390bfc209196caecfc1e Mon Sep 17 00:00:00 2001 From: dakkar Date: Fri, 29 Jun 2018 14:41:12 +0000 Subject: print HTTP conversation on errors --- tweet-archive.pl | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/tweet-archive.pl b/tweet-archive.pl index 2424206..b78540f 100644 --- a/tweet-archive.pl +++ b/tweet-archive.pl @@ -21,11 +21,25 @@ my $conf = $json_parser->decode( my $client = Dakkar::TweetArchive->new($conf); my $store = Dakkar::TweetArchive::Store->new($conf); -my $latest_id = $store->latest_tweet_id; +my $ua = $client->client->ua; +my @responses; +$ua->add_handler( response_done => sub { push @responses, $_[0]; return } ); -for my $tweet ($client->home_timeline($latest_id)->@*) { - $store->store_tweet($tweet); -} +eval { + my $latest_id = $store->latest_tweet_id; -$store->store_friends($client->friends); -$store->store_followers($client->followers); + for my $tweet ($client->home_timeline($latest_id)->@*) { + $store->store_tweet($tweet); + } + + $store->store_friends($client->friends); + $store->store_followers($client->followers); + 1; +} or do { + print "Fail: $@\n"; + for my $res (@responses) { + print $res->request->as_string; + print $res->as_string; + print "\n",'-' x 50,"\n\n"; + } +}; -- cgit v1.2.3