Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Re: XML::Simple conflicts with $SIG{__DIE__}

by Matts (Deacon)
on Apr 18, 2002 at 13:43 UTC ( #160198=note: print w/ replies, xml ) Need Help??


in reply to Re: XML::Simple conflicts with $SIG{__DIE__}
in thread XML::Simple conflicts with $SIG{__DIE__}

Or perhaps more properly, any $SIG{__DIE__} handler you install should only ever be used to augment the exception and re-throw it. Anything else completely breaks perl's exception handling mechanism. Here's a working (and useful) example of a good $SIG{__DIE__} handler:

local $SIG{__DIE__} = sub { my $err = shift; if (ref($err)) { die $err; } else { throw Exception::Unknown (error => $err); } };
Implementation of the Exception::Unknown class is left as an exercise. Also note the use of local - so that if we're running under something like mod_perl we don't screw up everyone elses handler that might not want this effect.


Comment on Re: Re: XML::Simple conflicts with $SIG{__DIE__}
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://160198]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2015-07-30 01:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls