Changeset 82e0f26


Ignore:
Timestamp:
Aug 4, 2009, 1:30:08 AM (12 years ago)
Author:
Kevin Riggle <kevinr@free-dissociation.com>
Branches:
master, release-1.7, release-1.8, release-1.9
Children:
513da71
Parents:
5da6ed8
Message:
Use exceptions in the modern, Net::Twitter::Lite style of error handling
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/BarnOwl/Module/Twitter/Handle.pm

    r5da6ed8 r82e0f26  
    5757    $self->{twitter}  = Net::Twitter::Lite->new(%twitter_args);
    5858
    59     my $timeline = $self->{twitter}->friends_timeline({count => 1});
     59    my $timeline = eval { $self->{twitter}->friends_timeline({count => 1}) };
     60    warn "$@" if $@;
    6061
    6162    if(!defined($timeline)) {
     
    7172        $self->{last_direct} = $self->{twitter}->direct_messages()->[0]{id};
    7273    };
     74    warn "$@" if $@;
    7375    $self->{last_direct} = 1 unless defined($self->{last_direct});
    7476
     
    7678        $self->{twitter}->{ua}->timeout(1);
    7779    };
     80    warn "$@" if $@;
    7881
    7982    return $self;
     
    8386    my $self = shift;
    8487
    85     my $ratelimit = $self->{twitter}->rate_limit_status;
     88    my $ratelimit = eval { $self->{twitter}->rate_limit_status };
     89    warn "$@" if $@;
    8690    unless(defined($ratelimit) && ref($ratelimit) eq 'HASH') {
    8791        # Twitter's just sucking, sleep for 5 minutes
     
    107111    return unless BarnOwl::getvar('twitter:poll') eq 'on';
    108112
    109     my $timeline = $self->{twitter}->friends_timeline( { since_id => $self->{last_id} } );
     113    my $timeline = eval { $self->{twitter}->friends_timeline( { since_id => $self->{last_id} } ) };
     114    warn "$@" if $@;
    110115    unless(defined($timeline) && ref($timeline) eq 'ARRAY') {
    111116        $self->twitter_error();
     
    114119
    115120    if ($self->{cfg}->{show_unsubscribed_replies}) {
    116         my $mentions = $self->{twitter}->mentions( { since_id => $self->{last_id} } );
     121        my $mentions = eval { $self->{twitter}->mentions( { since_id => $self->{last_id} } ) };
     122        warn "$@" if $@;
    117123        unless (defined($mentions) && ref($mentions) eq 'ARRAY') {
    118124            $self->twitter_error();
     
    158164    return unless BarnOwl::getvar('twitter:poll') eq 'on';
    159165
    160     my $direct = $self->{twitter}->direct_messages( { since_id => $self->{last_direct} } );
     166    my $direct = eval { $self->{twitter}->direct_messages( { since_id => $self->{last_direct} } ) };
     167    warn "$@" if $@;
    161168    unless(defined($direct) && ref($direct) eq 'ARRAY') {
    162169        $self->twitter_error();
Note: See TracChangeset for help on using the changeset viewer.