in reply to Re: Error handling - how much/where/how?
in thread Error handling - how much/where/how?
If I were to use a module that returns your proposed { 'value'=>(0..N), 'is-valid'=>(0,1) } the very first thing I'd make would be a
and ran all exported functions through this wrapper to get some sanely behaving ones. You have exceptions for Lary's sake! Use'm!sub sanify { my $fun = shift; return sub { my $ret = $fun->(@_); if ($ret->{'is-valid') { return $ret->{'value'} } else { die "Well, something was incomplete. The module author gave no clue +s!\n"; } } }
Update: <quote>In general, it's a good idea to put your error handling as low as possible.</quote>
Let me disagree. If you put the error handling too low, you end up with much longer code. And longer code takes longer to write and it means more bugs. So you should always try to find the right level to handle errors. Not too low nad not too high. I'm afraid apart from experience there is no way to tell what level is the right one. I just think you should not be afraid to say "I don't mind whether it's this or this or this operation that fails, if any of them does I want to handle the problem like this."
Jenda
XML sucks. Badly. SOAP on the other hand is the most powerfull vacuum pump ever invented. |
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Error handling - how much/where/how?
by mstone (Deacon) on Jun 15, 2005 at 20:34 UTC | |
by Jenda (Abbot) on Jun 16, 2005 at 00:43 UTC |