|We don't bite newbies here... much|
An uncatchable dieby dws (Chancellor)
|on Feb 02, 2005 at 06:08 UTC||Need Help??|
I've stumbled on a use of die that can't be caught with an eval.
In most normal uses,
will let you simulate an exception being thrown and caught. If somewhere inside of something_that_might_die() there's a
the string will end up in $@. This almost always works.
The case where this throw/catch mechanism doesn't work is inside a destructor. The code
and the die disappears (on Perl 5.6
so the die is being caught, but just not in a place that you can necessarily get at and catch yourself.
This doesn't surprise me. Object destruction is an interesting edge case, and it makes a certain amount of sense to ignore errors. Still, if you're depending on wrapping a bunch of code in an eval to trap exceptions, and some of that code is doing cleanup in constructors that might fail, the lost exception might come as a rude surprise.
Update: More experiments. This is looking like a pre 5.8 vs post 5.8 thing.