8 ms·
"Right tool for the right job" Exceptions are an extremely useful and widely used tool for dealing cleanly with certain classes of errors (through a non-local
by YorkshireSeason 8y ago
"Right tool for the right job"
Exceptions are an extremely useful and widely used tool for dealing
cleanly with certain classes of errors (through a non-local jump out of a context to a dynamically bound target), let's call them simple
errors. Maybe something that can be oversimplified like this:
def main ( ... )
try
...
catch
case e => print "Something's wrong, aborting"
(Note that in Go's original main use case (writing low-level servers), such simple error handling is rarely what's needed.) If you need restarts etc, then standard exceptions are not the right
tool. In my experience, it's worthwhile to stop thinking about errors in such
situations but see the behaviour that you are tempted to classify erroneous as part of the normal algorithm, using control constructs other than exceptions.