Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Best Practices for Exception Handling

by yosefm (Friar)
on Jul 11, 2003 at 14:43 UTC ( #273381=note: print w/ replies, xml ) Need Help??


in reply to Best Practices for Exception Handling

Another way of treating an error or warning as an event (which I have only learned a while ago and found useful) is to define handlers for it using:

local $SIG{__WARN__} = \&HandlerSub; local $SIG{__DIE__} = \&OtherHandler;

But the problem with it is that you really must pay attention to your use of warn and die, as well as conditions when something not written by you might die.


Comment on Re: Best Practices for Exception Handling
Download Code
Re^2: Best Practices for Exception Handling
by adrianh (Chancellor) on Jul 11, 2003 at 18:24 UTC

    There are problems when you mix the signal handling style with other modules that use exception handling, or use it in persistent environments like mod_perl so (in my opinion) it is best avoided.

    Alternative Exception Handling Techniques in the mod_perl guide has more info on this. Also see the documentation on $^S (in perlvar) and die.

    It's often simpler just to override CORE::GLOBAL::die and CORE::GLOBAL::warn.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (2)
As of 2014-10-20 23:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (93 votes), past polls