Skip Menu |

This queue is for tickets about the TryCatch CPAN distribution.

Report information
The Basics
Id: 46294
Status: open
Priority: 0/
Queue: TryCatch

People
Owner: Nobody in particular
Requestors: peter [...] makholm.net
Cc:
AdminCc:

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



Subject: Garbage collection might break TryCatch
If an object goes out of scope while leaving the try-block, the objects DESTROY method might clear $@ and thus breaking TryCatch's exception handling. See the attached example.
Subject: try_trycatch.pl
#!/usr/bin/perl use warnings; use strict; package Foo; sub new { my $class = shift; return bless {}, $class; } sub DESTROY { my $self = shift; eval { 1; }; } package main; use TryCatch; sub throw { $TryCatch::Exception = shift; die $TryCatch::Exception; } try { my $foo = Foo->new(); open my $fh, ">", "/" or throw( "Could not open /: $!" ); } catch ($err) { print STDERR "Something bad happened: $err\n"; }; print "Done\n";