next up previous contents FITSIO Home
Next: Variable-Length Array Facility in Up: Basic FITSIO Conventions Previous: Data Scaling

Error Status Values and the Error Message Stack

The last parameter in nearly every FITSIO subroutine is the error status value which is both an input and an output parameter. A returned positive value for this parameter indicates an error was detected. A listing of all the FITSIO status code values is given at the end of this document.

The FITSIO library uses an `inherited status' convention for the status parameter which means that if a subroutine is called with a positive input value of the status parameter, then the subroutine will exit immediately without changing the value of the status parameter. Thus, if one passes the status value returned from each FITSIO routine as input to the next FITSIO subroutine, then whenever an error is detected all further FITSIO processing will cease. This convention can simplify the error checking in application programs because it is not necessary to check the value of the status parameter after every single FITSIO subroutine call. If a program contains a sequence of several FITSIO calls, one can just check the status value after the last call. Since the returned status values are generally distinctive, it should be possible to determine which subroutine originally returned the error status.

FITSIO also maintains an internal stack of error messages (80-character maximum length) which in many cases provide a more detailed explanation of the cause of the error than is provided by the error status number alone. It is recommended that the error message stack be printed out whenever a program detects a FITSIO error. To do this, call the FTGMSG routine repeatedly to get the successive messages on the stack. When the stack is empty FTGMSG will return a blank string. Note that this is a `First In - First Out' stack, so the oldest error message is returned first by ftgmsg.

In some situations programs may encounter a non-fatal FITSIO error and will want to continue processing. An example is when a program fails to find an optional keyword in the header and FITSIO returns status = 202. The program may ignore this error and reset status=0, however this may still leave error messages on the stack. To clear the entire message stack in this situation, call the FTCMSG subroutine.


next up previous contents FITSIO Home
Next: Variable-Length Array Facility in Up: Basic FITSIO Conventions Previous: Data Scaling