View | Details | Raw Unified | Return to bug 3186
Collapse All | Expand All

(-)a/C4/SMS.pm (-6 / +14 lines)
Lines 75-91 sub send_sms { Link Here
75
    return unless $driver;
75
    return unless $driver;
76
76
77
    # warn "using driver: $driver to send message to $params->{'destination'}";
77
    # warn "using driver: $driver to send message to $params->{'destination'}";
78
    
78
79
    # Create a sender
79
    my ($sent, $sender);
80
    my $sender = SMS::Send->new( $driver,
80
    eval {
81
        # Create a sender
82
        $sender = SMS::Send->new( $driver,
81
                                 _login    => C4::Context->preference('SMSSendUsername'),
83
                                 _login    => C4::Context->preference('SMSSendUsername'),
82
                                 _password => C4::Context->preference('SMSSendPassword'),
84
                                 _password => C4::Context->preference('SMSSendPassword'),
83
                            );
85
                            );
84
    
86
    
85
    # Send a message
87
        # Send a message
86
    my $sent = $sender->send_sms( to   => $params->{'destination'},
88
        $sent = $sender->send_sms( to   => $params->{'destination'},
87
                                  text => $params->{'message'},
89
                                  text => $params->{'message'},
88
                             );
90
                             );
91
    };
92
    #We might die because SMS::Send $driver is not defined or the sms-number has a bad format
93
    #Catch those errors and fail the sms-sending gracefully.
94
    if ($@) {
95
        warn $@;
96
        return undef;
97
    }
89
    # warn 'failure' unless $sent;
98
    # warn 'failure' unless $sent;
90
    return $sent;
99
    return $sent;
91
}
100
}
92
- 

Return to bug 3186