Ari has asked for the wisdom of the Perl Monks concerning the following question:
How much error handling should you build in? For example, I have a very simple program that takes one sort of ID and converts it to another in about 15 separate stages. Should I build in error handling at each stage (similar to below) or only at the places where it's highly likely to fail after bad data?
else { print STDERR; die ("Unable to proceed. ID may be invalid. Exiting.\n");
(Initial input and the first calculations at the main concern - after that, there's almost no chance of error.)
I don't want to overdo it, same as I don't want to overcomment, but I also don't want to leave later maintainers wondering why it wasn't set up properly to start with!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Error handling
by GrandFather (Saint) on Sep 17, 2012 at 22:14 UTC | |
|
Re: Error handling
by choroba (Cardinal) on Sep 17, 2012 at 21:26 UTC | |
by Ari (Acolyte) on Sep 17, 2012 at 21:45 UTC | |
by chromatic (Archbishop) on Sep 17, 2012 at 21:52 UTC | |
|
Re: Error handling
by Marshall (Canon) on Sep 18, 2012 at 08:20 UTC | |
by Ari (Acolyte) on Sep 18, 2012 at 13:37 UTC | |
|
Re: Error handling
by AnomalousMonk (Archbishop) on Sep 17, 2012 at 21:21 UTC |