DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
An Objection Class for Rudimentary Error Handling - Objection(C++)

Objections for the Software Client

Our example client programmer is a user of the Stack library. This programmer understands when an Objection may be raised and understands the default and recovery actions associated with that Objection in each instance in which it may occur.

The client programmer has three choices of action regarding any Objection which may be raised. The user can:

  1. Sustain the Objection, by not addressing the Objection at all, or by explicitly requesting that the default action take place when an error occurs.

  2. Ignore the Objection, causing the recovery action to take place when an error occurs.

  3. Supersede the Objection, by appointing a user-defined initial handler to perform specific functions when an error occurs which replace or augment the library actions.

The Objection operations used by a client programmer to determine what will happen when an Objection is raised are Objection::ignore() and Objection::appoint(). A call to appoint() with no arguments, e.g., Stack::underflow.appoint(), associates an initial handler that will invoke the subsequent handler (the default action). The user calls the ignore() function, e.g., Stack::underflow.ignore(), to ignore the error. ignore() associates an initial handler which will bypass the subsequent handler and thus the recovery action will be performed when the Objection is raised.

The client can also pass to appoint() an initial handler to be associated with the Objection, for example, Stack::underflow.appoint(function). The type of the argument to appoint() is Objection_action*, which is defined by the Objection library to be the name of a user-defined function which has one argument of type const char* and returns an integer


NOTE: To the Library Author: if a function has been appointed by the client, the integer returned from this function is the value which will be returned to the library when an Objection is raise()'ed. (See ``Objections for the Software Author'').

The integer returned from this new initial handler determines whether the subsequent handler (and thus the default action) is executed (return 0) or whether the recovery (return non-zero) action happens after the Objection is raised and the function has been executed. The const char* argument to the user-defined function is an error message passed to the function from the library.

The appoint() and ignore() functions return an Objection_action*, whose value is the previous action associated with the Objection.

The rest of this section will illustrate how the Stack library client associates actions with Objections.


Next topic: Sustaining an Objection
Previous topic: Documenting Software using Objections

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005