Skip Menu |

This queue is for tickets about the Error CPAN distribution.

Report information
The Basics
Id: 32638
Status: resolved
Worked: 30 min
Priority: 0/
Queue: Error

People
Owner: Nobody in particular
Requestors: hchbaw [...] laafc.net
Cc:
AdminCc:

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



Subject: 'except' doesn't take an argument as described in the documents.
I have perl-5.8.8, the latest Error-0.17011 running on Debian(sid). I noticed that below simple example which are basically snipped from the Error synopsis yields 'Use of uninitialized value in print'. try { throw Error::Simple( "message" ); } except { my $E = shift; my $general_handler=sub { print $E->{-text}}; # <== using uninitialized $E. return { 'Error::Simple' => $general_handler, } } Attached patch should fix this. Cheers.
Subject: except.txt
'except' doesn't take an argument as described in the documents. I have perl-5.8.8, the latest Error-0.17011 running on Debian(sid). I noticed that below simple example which are basically snipped from the Error synopsis yields 'Use of uninitialized value in print'. try { throw Error::Simple( "message" ); } except { my $E = shift; my $general_handler=sub { print $E->{-text}}; # <== using uninitialized $E. return { 'Error::Simple' => $general_handler, } } Attached patch should fix this. Cheers. diff --exclude='*.old' -uNr Error-0.17011.orig/lib/Error.pm Error-0.17011/lib/Error.pm --- Error-0.17011.orig/lib/Error.pm 2007-12-25 17:39:22.000000000 +0900 +++ Error-0.17011/lib/Error.pm 2008-01-25 14:22:10.000000000 +0900 @@ -317,7 +317,7 @@ my $pkg = $catch->[$i]; unless(defined $pkg) { #except - splice(@$catch,$i,2,$catch->[$i+1]->()); + splice(@$catch,$i,2,$catch->[$i+1]->($err)); $i -= 2; next CATCHLOOP; } diff --exclude='*.old' -uNr Error-0.17011.orig/t/13except-arg0.t Error-0.17011/t/13except-arg0.t --- Error-0.17011.orig/t/13except-arg0.t 1970-01-01 09:00:00.000000000 +0900 +++ Error-0.17011/t/13except-arg0.t 2008-01-25 14:21:50.000000000 +0900 @@ -0,0 +1,22 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Error qw(:try); +use Test::More tests => 2; + +my $arg_0; + +try { + throw Error::Simple( "message" ); +} +except { + $arg_0 = shift; + return { + 'Error::Simple' => sub {}, + }; +}; + +ok( defined $arg_0, 'defined( $_[0] ) after throw/except' ); +ok( ref $arg_0 && $arg_0->isa( "Error::Simple" ), '$_[0]->isa( "Error::Simple" ) after throw/except' );
Thanks for your contribution! I applied the patch in the newly released Error-0.17012. Next time, you should use the Subversion repository. Thanks again. Regards, Shlomi Fish