Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^7: Use of "die" in OO modules

by adrianh (Chancellor)
on Jan 28, 2007 at 21:31 UTC ( #596990=note: print w/ replies, xml ) Need Help??


in reply to Re^6: Use of "die" in OO modules
in thread Use of "die" in OO modules

Are you saying that if I eval { die MyExceptionClass->new(...) }; that the $@ variable will contain the instance of MyExceptionClass?

Exactly ;-) From perldoc die:

die() can also be called with a reference argument. If this happens to be trapped within an eval(), $@ contains the reference. This behavior permits a more elaborate exception handling implementation using objects that maintain arbitrary state about the nature of the exception. Such a scheme is sometimes preferable to matching particular string values of $@ using regular expressions.


Comment on Re^7: Use of "die" in OO modules
Re^8: Use of "die" in OO modules
by theguvnor (Chaplain) on Jan 30, 2007 at 00:37 UTC

    Awesome.. I tried it and I like it!

    Now I just wish that something like this:

    catch (ThisClass $e) {...} catch (ThatClass $e) {...}
    was built into Perl!!

    [Jon]

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2014-09-18 23:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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











    Results (126 votes), past polls