error handling techniques?

Alan S. Mazer alan at cogswell.Jpl.Nasa.Gov
Sat Nov 3 07:58:31 AEST 1990


I'm interested in what approaches people use for error handling, particularly
in general purpose function libraries and large software systems.  If someone
can reference a text or article, that would be good.  

Meanwhile, to give an example of the type of stuff I'm thinking of, here are
some examples.  Say you're writing a function library.  When you detect an
error (the distinction between user and internal errors is ignored here) you
can

1. Set an error code (similar to errno in Unix) and return -1, leaving the
   application to check for specific errors or print out one of a supplied
   set of messages.
2. Call an application-specified error handler, and if none, call a default
   error handler.
3. Print out a message from the package.  (Where this should be displayed
   and how is also a factor.  It may not be possible to write to the user's
   terminal.)

Similarly, say an application discovers that it has some internal error.
Should it

1. Print a message and dump core.
2. Save some transparently-maintained log of user actions to disk along with
   a message indicating what's happened.
3. Provide a traceback of function calls and ask the user whether or not to
   continue.

What other approaches are there?
-- 

-- Alan			       # My aptitude test in high school suggested that
   ..!ames!elroy!alan	       # I should become a forest ranger.  Take my
   alan at elroy.jpl.nasa.gov     # opinions on computers with a grain of salt.



More information about the Comp.lang.c mailing list