From b493adecf99f7cc114f61520cb0a0ce5d58a3117 Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Sat, 5 Nov 2022 17:03:50 -0500 Subject: [PATCH] Revise exception handling The directive processed is now still emailed if a simple exception terminates processing a packet. Previously, the directive text was only emailed during normal processing or if a structured exception was thrown. --- gatekeeper.pl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/gatekeeper.pl b/gatekeeper.pl index 937b615..68029b5 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -2663,17 +2663,17 @@ foreach my $packet (@packets) { # each list element is an array reference } else { local $Phase = 'RP'; - if (ref $@) { - # Processing explicitly threw an exception - my $E = $@; # preserve the exception, since many functions use eval + my $E = $@; # preserve the exception, since many functions use eval - unless ($oplist) { - # The directive text is emailed immediately after $oplist is set, - # so if $oplist is not set, then we still need to send it. Do so now. - mail($directive_text,0,'debug: directive file contents') - if $directive_text && DEBUG; - } + unless ($oplist) { + # The directive text is emailed immediately after $oplist is set, + # so if $oplist is not set, then we still need to send it. Do so now. + mail($directive_text,0,'debug: directive file contents') + if $directive_text && DEBUG; + } + if (ref $E) { + # Processing explicitly threw an exception if ($E->type_p('directive_syntax')) { mail(join("\n",$E->summary,'',$E->trace_msg),1); } elsif ($E->type_p('package_configuration')) { @@ -2690,7 +2690,7 @@ foreach my $packet (@packets) { # each list element is an array reference # exceptions thrown using die, used to reflect system errors like # failures of commands or operations that we know should succeed, # such as opening a file that we already know exists. - warn "error during processing: $@"; + warn "error during processing: $E"; } # clean up files if we abort while processing a triplet -- 2.25.1