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
Download (untitled) / with headers
text/plain 178b
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
Download try_trycatch.pl
text/x-perl 479b
#!/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";


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.