What Your Error Reporting Function Should Do

Your error reporting function should reset VV_ERR to zero, except for errors you intend to handle by code within your program. In this case, the error handling code should not set VV_ERR to zero. After the error is processed, you should set VV_ERR to zero.

The error reporter is passed the name of the function that detected the error and also has access to the global error code. Using the information available to it, your error function can:

Generally, we recommend that you do not continue processing after calling the error function. If you continue, you must handle the error before going on.

If you are going to call any Vermont Views functions in your error reporting function, you will have to first (1) save the error code value and (2) reset VV_ERR to 0. You must do this because the error function will be called again by the Vermont Views function when it discovers that VV_ERR is a non-zero value.

Accessing the System Error Messages

The system error message corresponding to given error code can be accessed with:

UCHAR *vv_errmsg(VV_ERR)

To display the message corresponding to the current value of the error code in window wnp:

v_st(vv_errmsg(VV_ERR), wnp); 

General Considerations

An error reporter is a single function designed to act on errors that occur during the running of a program. Because different types of errors will need different treatment, a useful error reporter will generally need to contain code sections that are conditional on the type of error. Because the handling of errors is often context-sensitive, not all errors can be appropriately handled by an error reporter.

One example of an error that generally cannot be handled internally is one due to insufficient memory. If a sequence of memory allocations cannot be completed, it will generally be desirable to release previously allocated memory. Releasing this memory must be done from the program rather than from the error function.

The name string passed to the error reporter can be used to assist in separating errors into different categories. The string can be used as a key to locate additional function-specific information. For example, you could place functions into several categories, each of which would be handled differently. One category might be functions whose errors cannot be handled internally, but need to be handled by the higher level function that called it. For this category, the error reporter would take no action, except perhaps to set a global indicating that further action is required at a higher level.


Home Contents Previous Next