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;
15 my $bot = Net::Twitter::Lite->new;
18 if (defined $ARGV[0] and $ARGV[0] eq "-d") {
23 foreach my $id (@ARGV) {
26 my $res = $bot->show_status($id);
27 foreach my $line (split /\n/, Dumper $res) {
28 if ($line =~ /undef/) { next; }
30 unless ($line =~ / => {/
51 # output error message at eval error
53 use Scalar::Util qw(blessed);
55 if (blessed $@ && $@->isa('Net::Twitter::Lite::Error')) {
57 if ($@->twitter_error) {
58 my %twitter_error = %{$@->twitter_error};
60 $twitter_error{"$_ => "} = $twitter_error{$_} . "\n";
61 delete $twitter_error{$_}
62 } keys %twitter_error;
63 warn join("", %twitter_error);