next up previous contents FITSIO Home
Next: 2. Example FITSIO Programs Up: 1.4 Basic Conventions used Previous: 1.4.5 Data Scaling   Contents

1.4.6 Error Status Values and the Error Message Stack

The last parameter in nearly every subroutine is the integer error status value that is both an input and an output parameter. A returned positive value for this parameter indicates an error was detected; negative values are reserved for non-fatal warning messages. A listing of all the possible status code values is given at the end of the `FITSIO User's Guide'. 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 occurs 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, for example, 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. The example programs listed in this cookbook generally only check the status value at the end of the program for simplicity, but it would be better programming practice to check the status value more frequently to trap any errors closer to their source.

FITSIO also generates an internal stack of error messages whenever an error occurs. These error messages in general provide a much more detailed explanation of the cause of the error than is provided by the error status number alone. It it recommended that the error message stack be printed out whenever a program detects a FITSIO error. The PRINTERROR subroutine given in this Cookbook provides an example of how to make use of the error message stack.


next up previous contents FITSIO Home
Next: 2. Example FITSIO Programs Up: 1.4 Basic Conventions used Previous: 1.4.5 Data Scaling   Contents