Subject: | Bug catching exception during initialization with defined destroy method |
Perl version v5.8.8 built for MSWin32-x86-multi-thread
WinXP Pro 2002 sp2
This issue happens when an exception is thrown inside the
initialization method. When a defined destroy method is in the same
class which may include an eval statement or call to outside code that
contains an eval statement the original exception thrown from the
initialization method fails silently.
If destroy should always be called even in the event of an exception
perhaps $@ should be retained before and after destroy.
#################################
package MyTest;
{
use strict;
use warnings;
use lib qw( ./lib/site/ ./lib/ );
use Object::InsideOut;
sub init :INIT
{
die "TEST";
my $this = shift;
}
sub destroy :DESTROY
{
# Remove line below to allow init exception to be caught.
# return if $@;
my $this = shift;
eval { "In Destroy" };
}
}
my $etl = eval { MyTest->new() };
if (my $e = Exception::Class->caught())
{
print "Caught Error!";
}
1;