8 # When Net::Twitter::Lite encounters a Twitter API error or a network error,
9 # it throws a Net::Twitter::Lite::Error object.
10 # You can catch and process these exceptions by using eval blocks and testing $@
11 ## from http://search.cpan.org/perldoc?Net::Twitter::Lite#ERROR_HANDLING
12 use Net::Twitter::Lite::WithAPIv1_1;
15 my $bot = Net::Twitter::Lite::WithAPIv1_1->new(
16 legacy_lists_api => 0,
20 if (defined $ARGV[0] and $ARGV[0] eq "-d") {
25 foreach my $id (@ARGV) {
28 my $res = $bot->show_status($id);
29 foreach my $line (split /\n/, Dumper $res) {
30 if ($line =~ /undef/) { next; }
32 unless ($line =~ / => {/
53 # output error message at eval error
55 use Scalar::Util qw(blessed);
57 if (blessed $@ && $@->isa('Net::Twitter::Lite::Error')) {
59 if ($@->twitter_error) {
60 my $twitter_error = $@->twitter_error;
61 if (defined $twitter_error->{errors}) {
62 foreach my $error (@{$twitter_error->{errors}}) {
63 warn "code => " , $error->{code}, "\n";
64 warn "message => ", $error->{message}, "\n";
68 # unknown HASH structure
70 warn Dumper $twitter_error;