Skip to content

Commit

Permalink
Ensure $@ is not overwritten
Browse files Browse the repository at this point in the history
  • Loading branch information
abeverley committed Jul 8, 2024
1 parent 2f6ce46 commit b36481f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/Dancer2/Core/App.pm
Original file line number Diff line number Diff line change
Expand Up @@ -898,14 +898,15 @@ sub template {
});
# Catch any exceptions that may happen during template processing
my $content = eval { $template->process( @_ ) };
my $eval_result = $@;
$self->set_with_return($old_with_return);
# If there was a previous response set before the exception (or set as
# part of the exception handling), then use that, otherwise throw the
# exception as normal
if ($local_response) {
$self->with_return->($local_response);
} elsif ($@) {
die $@;
} elsif ($eval_result) {
die $eval_result;
}
return $content;
}
Expand Down

0 comments on commit b36481f

Please sign in to comment.