|go ahead... be a heretic|
novice 'die' help requestedby nmerriweather (Friar)
|on Jan 11, 2007 at 19:36 UTC||Need Help??|
nmerriweather has asked for the wisdom of the Perl Monks concerning the following question:
i make frequent use of die in eval blocks to trap errors.
my code often looks like this:
note, thats a simplified version.
my problem lies in these 2 lines:
load_via_id could die and toss an exception - at which point things work as they should. i want to catch that die.
my issue is that if i die on "invalid user" (note, this is a simple version, in practice, there could several of these custom die items chained, i want to treat that differently : i still want to die and exit the block and return an error , but I don't want to do the logging.
can anyone suggest a way to do that and keep a similar syntax/code ? the only thing i could figure out was to have a '$supress_warning' variable before the block, and set it for custom dies -- but that means i'd have to write the dies as
someone out there with more experience than me must have a suggestion! i hope!