Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: ken [...] nsds.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 1.06



Subject: Log::Report::try truncates multi-line die messages
Date: Wed, 7 Jan 2015 18:34:36 -0800
To: bug-Log-Report [...] rt.cpan.org
From: Ken Neighbors <ken [...] nsds.com>
When using "Log::Report::try" around some code which calls "die" with multiple lines (such as die Data::Dumper->Dump(...)), the internal effect of die_decode truncates all but the first line of the error message. I have patched Log/Report/Die.pm to keep all the lines in the message so that "die" acts more like "Log::Report::error" which reports all the lines. Here is a test case: #!/usr/bin/perl -w use Log::Report; Log::Report::try { die "This is the first of two lines.\nThis is the second line.\n"; Log::Report::error( "This is the first of two lines.\nThis is the second line." ); }; $@->reportFatal; You will find that the second line is omitted. If you comment out the "die" line you will see that Log::Report::error keeps both lines intact. Here is a patch of Log/Report/Die.pm: --- Die.pm.orig 2015-01-08 02:24:21.789115374 +0000 +++ Die.pm.new 2015-01-08 02:24:21.789115374 +0000 @@ -37,13 +37,17 @@ $text[0] =~ s/\s*[.:;]?\s*$err\s*$// # the $err is translation sensitive or delete $opt{errno}; - my $msg = shift @text; - length $msg or $msg = 'stopped'; + my @msg = ( shift @text ); + length $msg[0] or $msg[0] = 'stopped'; my @stack; foreach (@text) - { push @stack, [ $1, $2, $3 ] - if m/^\s*(.*?)\s+called at (.*?) line (\d+)\s*$/; + { if(m/^\s*(.*?)\s+called at (.*?) line (\d+)\s*$/ ) + { push @stack, [ $1, $2, $3 ]; + } + else + { push @msg, $_; + } } $opt{stack} = \@stack; $opt{classes} = [ 'perl', (@stack ? 'confess' : 'die') ]; @@ -52,7 +56,7 @@ = @{$opt{stack}} ? ($opt{errno} ? 'ALERT' : 'PANIC') : ($opt{errno} ? 'FAULT' : 'ERROR'); - ($dietxt, \%opt, $reason, $msg); + ($dietxt, \%opt, $reason, join("\n",@msg)); } "to die or not to die, that's the question"; Basically my change is to keep all lines which are not stack-trace lines in the @msg array and join them back together at the end. Ken

Message body is not shown because sender requested not to inline it.

Message body is not shown because sender requested not to inline it.

Subject: Re: [rt.cpan.org #101389] Log::Report::try truncates multi-line die messages
Date: Thu, 8 Jan 2015 09:30:52 +0100
To: Ken Neighbors via RT <bug-Log-Report [...] rt.cpan.org>
From: Mark Overmeer <mark [...] overmeer.net>
* Ken Neighbors via RT (bug-Log-Report@rt.cpan.org) [150108 02:35]: Show quoted text
> Wed Jan 07 21:35:28 2015: Request 101389 was acted upon. > Transaction: Ticket created by ken@nsds.com > Queue: Log-Report > Subject: Log::Report::try truncates multi-line die messages > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=101389 > > > When using "Log::Report::try" around some code which calls "die" with > multiple lines (such as die Data::Dumper->Dump(...)), the internal effect > of die_decode truncates all but the first line of the error message.
Excellent bugreport. Patch accepted for next release. -- Regards, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net