Skip Menu |

This queue is for tickets about the Log-Report CPAN distribution.

Report information
The Basics
Id: 91671
Status: resolved
Priority: 0/
Queue: Log-Report

People
Owner: Nobody in particular
Requestors: cpan [...] neonics.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.998
Fixed in: (no value)



Subject: BEGIN{ try{ error "foo" } } exits without a message
Calling Log::Report::error within a try{} within a BEGIN {} block results in the application terminating without any message nor a nonzero exit code rather than returning from the try{} block as per the documentation. Reproduce: perl -MLog::Report -e 'BEGIN { try { error "no-show" }; print "done: $@" }' Output: (none) Expected output: done: try-block stopped with ERROR: error: no-show Details: After some debugging I have determined what code is actually executed in Log::Report: * line 116, $reporter->{filters} is empty; * line 133, @$disp contains a Log::Report::Dispatcher::Try, which then causes: * line 136, $d->log(...) to be called, which merely pushes an exception that is ignored (even with the patch); * line 140, @last_call is empty; * line 145, $stop is true; * line 147 is executed (an exit()), as $^S is undefined. The documentation for $^S states that an undefined value does NOT indicate whether exceptions are being caught (see http://perldoc.perl.org/perlvar.html#%24^S). Proposed change: --- lib/Log/Report.pm (original) +++ lib/Log/Report.pm (patched) @@ -144,7 +144,7 @@ if($stop) { # ^S = EXCEPTIONS_BEING_CAUGHT, within eval or try - $^S or exit($opts->{errno} || 0); + (defined($^S) ? $^S : 1) or exit($opts->{errno} || 0); $! = $opts->{errno} || 0; $@ = $exception || Log::Report::Exception->new(report_opts => $opts
Subject: Re: [rt.cpan.org #91671] BEGIN{ try{ error "foo" } } exits without a message
Date: Thu, 26 Dec 2013 16:14:30 +0100
To: "https://openid.stackexchange.com/user/83939ede-74ea-4f6c-8bf4-a4539b9b5220 via RT" <bug-Log-Report [...] rt.cpan.org>
From: Mark Overmeer <mark [...] overmeer.net>
* https://openid.stackexchange.com/user/83939ede-74ea-4f6c-8bf4-a4539b9b5220 via RT (bug-Log-Report@rt.cpan.org) [131226 12:46]: Show quoted text
> Thu Dec 26 07:46:26 2013: Request 91671 was acted upon. > Transaction: Ticket created by https://openid.stackexchange.com/user/83939ede-74ea-4f6c-8bf4-a4539b9b5220 > Queue: Log-Report > Subject: BEGIN{ try{ error "foo" } } exits without a message > > perl -MLog::Report -e 'BEGIN { try { error "no-show" }; print "done: $@" }' > done: try-block stopped with ERROR: error: no-show > > - $^S or exit($opts->{errno} || 0); > + (defined($^S) ? $^S : 1) or exit($opts->{errno} || 0);
Well documented. Patch accepted. Who can I attribute this to? -- Thanks MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
fixed in 1.00