Skip to content

Commit

Permalink
Copy $@ to $e not to be cleared while logging
Browse files Browse the repository at this point in the history
  • Loading branch information
charsbar authored and rspier committed May 22, 2024
1 parent 88deb85 commit 5e92c29
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/pause_2017/PAUSE/Web/Plugin/WrapAction.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@ sub _wrap {
}

my $res = eval { $next->(); };
if ($@) {
if (UNIVERSAL::isa($@, "PAUSE::Web::Exception")) {
if ($@->{ERROR}) {
$@->{ERROR} = [ $@->{ERROR} ] unless ref $@->{ERROR} eq 'ARRAY';
push @{$pause->{ERROR}}, @{$@->{ERROR}};
if (my $e = $@) {
if (UNIVERSAL::isa($e, "PAUSE::Web::Exception")) {
if ($e->{ERROR}) {
$e->{ERROR} = [ $e->{ERROR} ] unless ref $e->{ERROR} eq 'ARRAY';
push @{$pause->{ERROR}}, @{$e->{ERROR}};
require Data::Dumper;
my $message = "Line " . __LINE__ . ", File: " . __FILE__ . "\n" . Data::Dumper->new([$pause->{ERROR}],[qw(error)])->Indent(1)->Useqq(1)->Dump;
$c->app->pause->log({level => 'debug', message => $message});
$c->res->code($@->{HTTP_STATUS}) if $@->{HTTP_STATUS};
$c->res->code($e->{HTTP_STATUS}) if $e->{HTTP_STATUS};
$c->render('layouts/layout') unless $c->stash('Action');
} elsif ($@->{HTTP_STATUS}) {
} elsif ($e->{HTTP_STATUS}) {
$c->res->headers->content_type('text/plain');
$c->res->body(status_message($@->{HTTP_STATUS}));
$c->rendered($@->{HTTP_STATUS});
$c->res->body(status_message($e->{HTTP_STATUS}));
$c->rendered($e->{HTTP_STATUS});
return;
}
} else {
# this is NOT a known error type, we need to handle it anon
my $error = "$@";
my $error = "$e";
if ($pause->{ERRORS_TO_BROWSER}) {
push @{$pause->{ERROR}}, " ", $error;
} else {
Expand Down

0 comments on commit 5e92c29

Please sign in to comment.