Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Using die() in methods

by moritz (Cardinal)
on Jul 06, 2014 at 16:47 UTC ( #1092478=note: print w/ replies, xml ) Need Help??


in reply to Using die() in methods

Anyway, using die() from the method really looks a bit odd.

It looks pretty normal to me.

Who really does that? Have you been always doing it that way or started to do it that way some time ago?

Lots of folks do it; it's how you're meant to handle errors, after all. Modules like autodie bring it to core functions in perl that were written before exceptions existed.

Anyway, exceptions are useful if they don't need to be always caught in the caller, but somtimes in the caller's caller, or higher up the call chain.

The second main benefit from exceptions is that if somebody forgets to handle them, it'll be very obvious. On the other hand if things go wrong and nobody notices, much more harm is done (say writing a config file fails, and thus work is silently lost, and nobody notices until much later), and it's much harder to debug.


Comment on Re: Using die() in methods

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2014-09-20 00:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (151 votes), past polls