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

Re: Nested evals - are they evil?

by radiantmatrix (Parson)
on Jul 31, 2007 at 15:27 UTC ( #629854=note: print w/ replies, xml ) Need Help??


in reply to Nested evals - are they evil?

This isn't what I'd call "nesting", and yes it is a little redundant. But, it's also harmless.

I'd guess that someone developed callMethod and did some cargo-cult error handling. There's not much point in catching an exception only to throw it again, but perhaps the coder planned on adding some additional handling code.

I'd further guess that later on, some developer (maybe the same one, maybe not) called callMethod, knowing only that it threw an error, and so caught it, and made the same cargo-cult mistake.

If all those various catching blocks (the if ($@) bits) are only re-throwing the error, then they are kind of pointless and redundant. They could probably be removed.

On the other hand, catching an exception and doing something useful about it (writing additional detail to the logs, asking the user what to do, retrying, etc.) is a good pattern, esp. for user-interactive programs. Always do the least surprising thing -- that is, whatever will least surprise your user.

<radiant.matrix>
Ramblings and references
The Code that can be seen is not the true Code
I haven't found a problem yet that can't be solved by a well-placed trebuchet

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2016-08-26 04:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The best thing I ever won in a lottery was:















    Results (365 votes). Check out past polls.