Skip to content

Commit 5722fe9

Browse files
committed
warn on warn not die
1 parent ea04561 commit 5722fe9

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

cgi-bin/page.fcgi

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,19 @@ $SIG{PIPE} = 'IGNORE';
168168

169169
# my ($stdin, $stdout, $stderr) = (IO::Handle->new(), IO::Handle->new(), IO::Handle->new());
170170
# https://stackoverflow.com/questions/14563686/how-do-i-get-errors-in-from-a-perl-script-running-fcgi-pm-to-appear-in-the-apach
171-
$SIG{__DIE__} = $SIG{__WARN__} = sub {
171+
$SIG{__WARN__} = sub {
172+
my $msg = join '', @_;
173+
if(open(my $fout, '>>', File::Spec->catfile($tmpdir, "$script_name.stderr"))) {
174+
print $fout $info->domain_name(), ": $msg";
175+
close $fout;
176+
# } else {
177+
# print $stderr $msg;
178+
}
179+
$logger->warn($msg) if($logger);
180+
};
181+
182+
$SIG{__DIE__} = sub {
183+
return if $^S; # Let Error.pm try/catch handle dies inside eval blocks
172184
my $msg = join '', @_;
173185
Log::WarnDie->dispatcher(undef);
174186
if(open(my $fout, '>>', File::Spec->catfile($tmpdir, "$script_name.stderr"))) {
@@ -178,7 +190,7 @@ $SIG{__DIE__} = $SIG{__WARN__} = sub {
178190
# print $stderr $msg;
179191
}
180192
$logger->fatal($msg) if($logger);
181-
CORE::die $msg;
193+
CORE::die @_;
182194
};
183195

184196
# my $request = FCGI::Request($stdin, $stdout, $stderr);

0 commit comments

Comments
 (0)