00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef WCSLIB_WCSLIB
00039 #define WCSLIB_WCSLIB
00040
00041 #include "cel.h"
00042 #include "fitshdr.h"
00043 #include "lin.h"
00044 #include "log.h"
00045 #include "prj.h"
00046 #include "spc.h"
00047 #include "sph.h"
00048 #include "spx.h"
00049 #include "tab.h"
00050 #include "wcs.h"
00051 #include "wcserr.h"
00052 #include "wcsfix.h"
00053 #include "wcshdr.h"
00054 #include "wcsmath.h"
00055 #include "wcsprintf.h"
00056 #include "wcstrig.h"
00057 #include "wcsunits.h"
00058 #include "wcsutil.h"
00059
00060 #endif
00061
01929 wcserr_enable(1);
01930 wcsprintf_set(stderr);
01931
01932 ...
01933
01934 if (wcsset(&wcs) {
01935 wcsperr(&wcs);
01936 return wcs.err->status;
01937 }
01938 @endverbatim
01939 In this example, if an error was generated in one of the prjset() functions,
01940 wcsperr() would print an error traceback starting with wcsset(), then
01941 celset(), and finally the particular projection-setting function that
01942 generated the error. For each of them it would print the status return value,
01943 function name, source file, line number, and an error message which may be
01944 more specific and informative than the general error messages reported in the
01945 first example. For example, in response to a deliberately generated error,
01946 the @c twcs test program, which tests wcserr among other things, produces a
01947 traceback similar to this:
01948 @verbatim
01949 ERROR 5 in wcsset() at line 1564 of file wcs.c:
01950 Invalid parameter value.
01951 ERROR 2 in celset() at line 196 of file cel.c:
01952 Invalid projection parameters.
01953 ERROR 2 in bonset() at line 5727 of file prj.c:
01954 Invalid parameters for Bonne's projection.
01955 @endverbatim
01956
01957 Each of the @ref structs "structs" in @ref overview "WCSLIB" includes a
01958 pointer, called @a err, to a wcserr struct. When an error occurs, a struct is
01959 allocated and error information stored in it. The wcserr pointers and the
01960 @ref memory "memory" allocated for them are managed by the routines that
01961 manage the various structs such as wcsini() and wcsfree().
01962
01963 wcserr messaging is an opt-in system enabled via wcserr_enable(), as in the
01964 example above. If enabled, when an error occurs it is the user's
01965 responsibility to free the memory allocated for the error message using
01966 wcsfree(), celfree(), prjfree(), etc. Failure to do so before the struct goes
01967 out of scope will result in memory leaks (if execution continues beyond the
01968 error).
01969 */
01970
01971