summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2018-06-29 14:41:12 +0000
committerdakkar <dakkar@thenautilus.net>2018-06-29 14:41:59 +0000
commit003db36ba6a6e8a5817f390bfc209196caecfc1e (patch)
treef8a810e200df3312859071e28499040cc4abd6a1
parentindex the tweets (diff)
downloadtweet-archive-003db36ba6a6e8a5817f390bfc209196caecfc1e.tar.gz
tweet-archive-003db36ba6a6e8a5817f390bfc209196caecfc1e.tar.bz2
tweet-archive-003db36ba6a6e8a5817f390bfc209196caecfc1e.zip
print HTTP conversation on errors
-rw-r--r--tweet-archive.pl26
1 files 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";
+ }
+};