Additional Error Handling Procedures
IRAF provides several procedures for handling errors in an iferr block. The errcode procedure returns the error code that was passed to the error() procedure. This allows the program to distinguish between different kinds of errors. The errget procedure also returns the error code and in addition returns the error message that was passed to the error() procedure. The erract procedure allows a program to repost the error that was caught by the iferr block. The erract procedure has one argument, the severity level of the error. There are three error levels and they are defined in the include file error.h. The two highest levels, EA_FATAL and EA_ERROR, correspond to the error levels produced by the procedures fatal() and error() respectively. Thus calling erract with the argument EA_FATAL is the same as calling fatal() with the same error that was previously posted by error(). Similarly, calling erract with the argument EA_ERROR is the same as calling error() again. The lowest error level is EA_WARN. If erract is called with an argument of EA_WARN, the error message is printed on the standard error stream and execution of the program proceeds as usual. The calling sequences for these three routines are the following.
Table 3.2: Error Handling Procedures.
The following example (Example 3.5) illustrates the use of the errcode and erract procedures. It converts all errors with a code of one to warnings and reposts all other errors as errors.
- Table 3.2: - Error Handling Procedures.
Generated with CERN WebMaker