https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14791
Lari Taskula <lari.task...@jns.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #42698|0 |1 is obsolete| | --- Comment #9 from Lari Taskula <lari.task...@jns.fi> --- Created attachment 62615 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=62615&action=edit Bug 14791: Resend failed notices - Add Koha::Exceptions to SMS::Send drivers Sometimes notices keep failing due to various reasons. One common problem is network connection failures. Because of this, the notices go into 'failed' status without another attempt for sending. This is very problematic, because we have to not only monitor the failed messages but also resend them manually. The purpose of this patch is to move us into more automated way of handling delivery failures. This patch enables us to handle exceptions in SMS messaging. The main idea is to throw an exception from SMS::Send driver in case of a failure. The exception will be caught by C4::SMS and from here it will be forwarded to C4::Letters where instead of automatically setting the message into 'failed' status, we now can do as we wish with various exceptions. As an example I have caught Koha::Exception::ConnectionFailed in C4::Letters::_send_message_by_sms(). When we catch the said exception, we simply leave the message in 'pending' status. This way it will be resent whenever process_message_queue.pl is executed again. There are multiple other reasons of failure where Exceptions will come in handy. For example the SMS Gateway provider may return some errors at request, and with this patch we will be able to handle them better. Below is a short example for making your SMS::Send driver throw an exception in case of a connection failure in SMS/Send/MyDriver/Driver.pm. _______________________________________________________________ use Koha::Exception::ConnectionFailed; sub send_sms { #.....your implementation..... # Throw an exception in case of a connection error # $connError can be for example: ($curl->{'retcode'} == 6) # cURL code 6: CURLE_COULDNT_RESOLVE_HOST if ($connError){ Koha::Exception::ConnectionFailed->throw(error => "Connection failed"); } #.....your implementation..... } _______________________________________________________________ prerequisites: -2. Set system preference SMSSendDriver to Example::ExceptionExample -1. Enable system preference EnhancedMessagingPreferences To test: 1. Have/create some pending sms messages into message_queue 2. Go to Patrons -> Notices 3. Observe that the your message is in pending status 4. Apply patch 5. Run misc/cronjob/process_message_queue.pl 6. Observe that your message is still in pending status You can also test it with your own implementation of SMSSendDriver. What you need to do is follow the example mentioned earlier to make send_sms() subroutine throw Koha::Exception::ConnectionFailed in case of a connection failure. -- You are receiving this mail because: You are watching all bug changes. _______________________________________________ Koha-bugs mailing list Koha-bugs@lists.koha-community.org http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/