Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

drhyde (1683)

drhyde
  (email not shown publicly)
http://www.cantrell.org.uk/david

Journal of drhyde (1683)

Thursday November 20, 2003
11:45 AM

__DIE__ handlers and eval

[ #15904 ]
At work I'm writing a large application. It uses an in-house logging module. That installs, amongst other things, a __DIE__ handler so we can log errors with a stack trace and all sorts of other goodness before exiting.

The front-end is a CGI script which uses the Template Toolkit. Some templates mysteriously logged stuff and stopped, muttering about us not having some Apache::* module installed. We tracked this down to TT trying to use the module in an eval.

Dear module authors, if you're going to eval stuff because you expect it to die, be aware that __DIE__ handlers *are* called when stuff dies in an eval. Please temporarily remove the __DIE__ handler before doing your voodoo, and then restore it.

And just to prove it ...

perl -e '$SIG{__DIE__} = sub { print "Foo\n"; exit(1); }; eval "use Apache::NonExistent;"; print "Bar" if $@'

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.