Commits

Anonymous committed 7f3583b

- t/11rethrow.t - added the test file by Thomas Equeter.
- Changed to the more correct behevaiour that fixes the rethrowning
error by Thomas Equeter.
- see http://rt.cpan.org/Public/Bug/Display.html?id=21612

Comments (0)

Files changed (5)

+Oct 07 2006 <shlomif@iglu.org.il> (Shlomi Fish)
+
+  Error.pm #0.17006
+  - t/11rethrow.t - added the test file by Thomas Equeter.
+  - Changed to the more correct behevaiour that fixes the rethrowning
+  error by Thomas Equeter.
+  - see http://rt.cpan.org/Public/Bug/Display.html?id=21612
+
 Oct 03 2006 <shlomif@iglu.org.il> (Shlomi Fish)
 
   Error.pm #0.17005
-<SOFTPKG NAME="Error" VERSION="0,17004,0,0">
+<SOFTPKG NAME="Error" VERSION="0,17005,0,0">
     <TITLE>Error</TITLE>
     <ABSTRACT>Error/exception handling in an OO-ish way</ABSTRACT>
     <AUTHOR>Graham Barr &lt;gbarr@pobox.com&gt;</AUTHOR>
 t/08warndie.t
 t/09dollar-at.t
 t/10throw-in-catch.t
+t/11rethrow.t
 t/lib/MyDie.pm

module/lib/Error.pm

 		    $code = $catch->[$i+1];
 		    while(1) {
 			my $more = 0;
-			local($Error::THROWN);
+			local($Error::THROWN, $@);
 			my $ok = eval {
 			    $@ = $err;
 			    if($wantarray) {
 	if(defined($owise = $clauses->{'otherwise'})) {
 	    my $code = $clauses->{'otherwise'};
 	    my $more = 0;
-        local($Error::THROWN);
+        local($Error::THROWN, $@);
 	    my $ok = eval {
 		$@ = $err;
 		if($wantarray) {

module/t/11rethrow.t

+#!/usr/bin/perl
+
+use Error qw(:try);
+use Test::More tests => 4;
+
+try {
+	try { die "inner" }
+	catch Error::Simple with { die "foobar" };
+}
+otherwise
+{
+	my $err = shift;
+    # TEST
+    ok (scalar($err =~ /foobar/), "Error rethrown");
+};
+
+try {
+	try { die "inner" }
+	catch Error::Simple with { throw Error::Simple "foobar" };
+}
+otherwise
+{
+	my $err = shift;
+    # TEST
+	ok (scalar("$err" =~ /foobar/), "Thrown Error::Simple");
+};
+
+try {
+	try { die "inner" }
+	otherwise { die "foobar" };
+}
+otherwise
+{
+    my $err = shift;
+    # TEST
+	ok (scalar("$err" =~ /foobar/), "die foobar");
+};
+
+try {
+	try { die "inner" }
+	catch Error::Simple with { throw Error::Simple "foobar" };
+}
+otherwise
+{
+	my $err = shift;
+    # TEST
+	ok (scalar($err =~ /foobar/), "throw Error::Simple");
+};
+
+1;