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 foreach my $id (@ARGV) {
19 my $res = $bot->show_status($id);
20 foreach my $line (split /\n/, Dumper $res) {
21 if ($line =~ /undef/) { next; }
22 unless ($line =~ / => {/
43 # output error message at eval error
45 use Scalar::Util qw(blessed);
47 if (blessed $@ && $@->isa('Net::Twitter::Lite::Error')) {
49 if ($@->twitter_error) {
50 my %twitter_error = %{$@->twitter_error};
52 $twitter_error{"$_ => "} = $twitter_error{$_} . "\n";
53 delete $twitter_error{$_}
54 } keys %twitter_error;
55 warn join("", %twitter_error);