Skip to content

Commit

Permalink
Merge pull request #522 from charsbar/remove_error_output2
Browse files Browse the repository at this point in the history
Log error messages via $c->app->pause->log instead of STDERR
  • Loading branch information
rspier committed May 22, 2024
2 parents b935e72 + 5e92c29 commit 7a66e85
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 18 deletions.
5 changes: 3 additions & 2 deletions lib/pause_2017/PAUSE/Web/Controller/Public.pm
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ sub mailpw {
# we have.
unless ($email = $rec->{secretemail}) {
my $u = $c->active_user_record($param,{hidden_user_ok => 1});
require YAML::Syck; print STDERR "Line " . __LINE__ . ", File: " . __FILE__ . "\n" . YAML::Syck::Dump({u=>$u}); # XXX

require YAML::Syck;
my $message = "Line " . __LINE__ . ", File: " . __FILE__ . "\n" . YAML::Syck::Dump({u=>$u});
$mgr->log({level => 'debug', message => $message});
$email = $u->{email};
}
if ($email) {
Expand Down
4 changes: 3 additions & 1 deletion lib/pause_2017/PAUSE/Web/Controller/Public/RequestId.pm
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ sub request {
userid => $userid,
rationale => $rationale,
};
require Data::Dumper; print STDERR "Line " . __LINE__ . ", File: " . __FILE__ . "\n" . Data::Dumper->new([$session->{APPLY}],[qw(APPLY)])->Indent(1)->Useqq(1)->Dump; # XXX
require Data::Dumper;
my $message = "Line " . __LINE__ . ", File: " . __FILE__ . "\n" . Data::Dumper->new([$session->{APPLY}],[qw(APPLY)])->Indent(1)->Useqq(1)->Dump;
$c->app->pause->log({level => 'debug', message => $message });
if (lc($fullname) eq lc($userid)) {
die PAUSE::Web::Exception->new(ERROR => "fullname looks like spam");
}
Expand Down
5 changes: 3 additions & 2 deletions lib/pause_2017/PAUSE/Web/Controller/User/Distperms.pm
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,9 @@ sub remove_dist_primary {
if (0) {
# here I discovered that Apache::Request has case-insensitive keys
my %p = map { $_, [ $req->every_param($_)] } @{$req->param->names};
require Data::Dumper; print STDERR "Line " . __LINE__ . ", File: " . __FILE__ . "\n" . Data::Dumper->new([\%p],[qw()])->Indent(1)->Useqq(1)->Dump; # XXX

require Data::Dumper;
my $message = "Line " . __LINE__ . ", File: " . __FILE__ . "\n" . Data::Dumper->new([\%p],[qw()])->Indent(1)->Useqq(1)->Dump;
$c->app->pause->log({level => 'debug', message => $message});
}

if (
Expand Down
5 changes: 3 additions & 2 deletions lib/pause_2017/PAUSE/Web/Controller/User/Perms.pm
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,9 @@ sub _share_remopr {
if (0) {
# here I discovered that Apache::Request has case-insensitive keys
my %p = map { $_, [ $req->every_param($_)] } @{$req->param->names};
require Data::Dumper; print STDERR "Line " . __LINE__ . ", File: " . __FILE__ . "\n" . Data::Dumper->new([\%p],[qw()])->Indent(1)->Useqq(1)->Dump; # XXX

require Data::Dumper;
my $message = "Line " . __LINE__ . ", File: " . __FILE__ . "\n" . Data::Dumper->new([\%p],[qw()])->Indent(1)->Useqq(1)->Dump;
$c->app->pause->log({level => 'debug', message => $message});
}

if (
Expand Down
23 changes: 12 additions & 11 deletions lib/pause_2017/PAUSE/Web/Plugin/WrapAction.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +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;
print STDERR "Line " . __LINE__ . ", File: " . __FILE__ . "\n" . Data::Dumper->new([$pause->{ERROR}],[qw(error)])->Indent(1)->Useqq(1)->Dump; # XXX
$c->res->code($@->{HTTP_STATUS}) if $@->{HTTP_STATUS};
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($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 7a66e85

Please sign in to comment.