LP#1749475 Improve error handling in send_event_email_output
authorDan Wells <dbw2@calvin.edu>
Thu, 21 Feb 2019 16:08:33 +0000 (11:08 -0500)
committerGalen Charlton <gmc@equinoxinitiative.org>
Mon, 14 Sep 2020 13:42:48 +0000 (09:42 -0400)
This code was borrowed from a few other places, so it still had the
$stat variable, but wasn't doing anything with it.  We might as well
go a step further and borrow the error handling that variable is there
for.

Ultimately, email handling should probably moved out to a utility
function rather than spread about.

Signed-off-by: Dan Wells <dbw2@calvin.edu>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Michele Morgan <mmorgan@noblenet.org>

Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm

index f2d7d1a..aa63e74 100644 (file)
@@ -1880,10 +1880,16 @@ sub send_event_email_output {
         $stat = $sender->send($email);
     } catch Error with {
         $err = $stat = shift;
-        $logger->error("resend_at_email: Email failed with error: $err");
+        $logger->error("send_event_email_output: Email failed with error: $err");
     };
 
-    return undef;
+    if( !$err and $stat and $stat->type eq 'success' ) {
+        $logger->info("send_event_email_output: successfully sent email");
+        return 1;
+    } else {
+        $logger->warn("send_event_email_output: unable to send email: ".Dumper($stat));
+        return 0;
+    }
 }
 
 __PACKAGE__->register_method(