home *** CD-ROM | disk | FTP | other *** search
- Notes on Clipper 5.0 runtime error handling.
-
-
- o The Error Block
-
- When an error occurs during execution of a compiled
- application, an automatic code block evaluation occurs.
- The block that is executed is known as the "error block."
- A single parameter is passed to the error block when it is
- evaluated. The parameter consists of a Clipper 5.0 Error
- object (see below).
-
-
-
- o The ErrorBlock() function
-
- The error block can be set or queried at any time using
- the ErrorBlock() function. The syntax for ErrorBlock() is
- shown here:
-
- ErrorBlock( [<bBlock>] ) <-- bCurrent
-
- Example:
-
- ErrorBlock( {|e| MyHandler(e)} )
-
-
-
- o The Default Error Block
-
- A default error block is installed by ERRORSYS.PRG during
- startup. This block causes errors to execute the default
- error handling code in ERRORSYS.PRG.
-
-
-
- o Installing a New Error Block
-
- If a subsystem wishes to install its own error handling,
- it should preserve the existing error block and restore it
- on exit. If the subsystem wishes to handle only a certain
- class of errors, it may pass other errors to the
- previously posted error block by evaluating it with the
- error object as a parameter.
-
-
-
- o Error objects
-
- Note: for a general discussion of Clipper 5.0 predefined
- objects, refer to the "Basic Concepts" chapter of the
- documentation.
-
- An Error object is a simple object that contains
- information pertaining to a runtime error. Error objects
- have no methods, only exported instance variables. When a
- runtime error occurs, a new Error object is created and
- passed as a parameter to the runtime error handler. The
- Error object can then be queried to determine the nature
- of the error condition.
-
-
-
- o Exported Instance Variables
-
- args
-
- For argument errors, an array containing the arguments
- that were supplied to the operator or function. For other
- errors, NIL.
-
-
- canDefault
-
- A logical value indicating whether the subsystem can
- perform default error recovery for the error condition. A
- value of true (.T.) indicates that default recovery is
- available. Availability of default handling, and the
- actual default recovery strategy, depend on the subsystem
- and the error condition. The minimum action is simply to
- ignore the error condition.
-
- Default recovery is requested by returning false (.F.)
- from the error block invoked to handle the error. Note:
- canDefault is never true if canSubstitute is true.
-
-
- canRetry
-
- A logical value indicating whether the subsystem can retry
- the operation that caused the error condition. A value of
- true (.T.) indicates that retry is possible. Retry may or
- may not be available, depending on the subsystem and the
- error condition.
-
- Retry is requested by returning true (.T.) from the error
- block invoked to handle the error. Note: canRetry is
- never true if canSubstitute is true.
-
-
- canSubstitute
-
- A logical value indicating whether a new result can be
- substituted for the operation which produced the error
- condition (argument errors and certain other simple errors
- allow the error handler to substitute a new result value
- for the failed operation). A value of true (.T.) means
- that substitution is possible.
-
- The substitution is performed by returning the new result
- value from the code block invoked to handle the error.
- Note: canSubstitute is never true if either canDefault or
- canRetry is true.
-
-
- cargo (Assignable)
-
- This instance variable is a user-definable slot, allowing
- arbitrary information to be attached to an Error object
- and retrieved later.
-
-
- description
-
- A character value containing a printable description of
- the error condition. A zero-length string indicates that
- the subsystem does not provide a printable description for
- the error. If the genCode instance variable is non-zero,
- a printable description is always available.
-
-
- filename
-
- A character value containing the name originally used to
- open the file associated with the error condition. A
- zero-length string indicates either that the error
- condition is not associated with a particular file or that
- the subsystem does not retain filename information.
-
-
- genCode
-
- A numeric value containing a Clipper generic error code.
- Generic error codes allow default handling of similar
- errors from different subsystems. A value of zero
- indicates that the error condition is peculiar to the
- subsystem and doesn't correspond to any of the generic
- error codes.
-
-
- operation
-
- A character value containing a printable description of
- the operation being attempted when the error occurred.
- For operators and functions, this is the name of the
- operator or function. For undefined variables or
- functions, this is the name of the variable or function.
- A zero-length string indicates that the subsystem does not
- provide a printable description of the operation.
-
-
- osCode
-
- A numeric value containing the operating system error code
- associated with the error condition. A value of zero
- indicates that the error condition was not caused by an
- error from the operating system.
-
-
- subCode
-
- A numeric value containing a subsystem-specific error
- code. A value of zero indicates that the subsystem does
- not assign any particular number to the error condition.
-
-
- subsystem
-
- A character value containing the name of the subsystem
- that generated the error. For errors in basic Clipper
- operators and functions, the subsystem name "BASE" is
- given. For errors generated by a database driver, the
- subsystem name is the name of the database driver.
-
-
- tries
-
- A numeric value indicating the number of times the failed
- operation has been attempted. When canRetry is true
- (.T.), this value can be used to limit the number of retry
- attempts. A value of zero indicates that the subsystem
- does not track the number of times the operation has been
- tried.
-
-
-
- o Examples
-
- Refer to the file ERRORSYS.PRG in the SOURCE directory for
- an example of an error block and associated runtime error
- handler.
-