Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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
Replies are listed 'Best First'.
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?

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2015-10-07 05:08 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (170 votes), past polls