Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
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.

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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://273381]
help
Chatterbox?
[james28909]: politicians making jobs for themselves? that is absurd! we all know how hard those politicians have it, having to take millions from lobbiest while screwing over their citizens. have a little sympathy why dont ya!

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2017-12-15 18:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (442 votes). Check out past polls.

    Notices?