Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2022-12-10 08:58 GMT
Find Nodes?
    Voting Booth?

    No recent polls found