Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Try::Tiny catch block with $_ eq ''

by sundialsvc4 (Abbot)
on May 17, 2013 at 13:32 UTC ( #1033973=note: print w/ replies, xml ) Need Help??


in reply to Try::Tiny catch block with $_ eq ''

What I prefer to use is Exception::Class, in conjunction with Try::Tiny.   You can die (that is, “throw an error”) with an object as well as with a string, and this gives you a well-defined way to communicate between the point of the error and its ultimate handler.   (Wrap “legacy code” sections in a handler that catches the (string ...) exceptions and throws an object containing, among other things, that string.)

An exception class can not only carry any sort of a “payload” (including undef values as-needed), but it is also self-identifying you have not only the class-name but the entire class hierarchy that you’ve cooked up.


Comment on Re: Try::Tiny catch block with $_ eq ''

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2015-07-04 17:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls