From: Jacob Bachmeyer Date: Sat, 5 Nov 2022 22:03:50 +0000 (-0500) Subject: Revise exception handling X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b493adecf99f7cc114f61520cb0a0ce5d58a3117;p=gatekeeper.git 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. --- 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