Closed kbarbary closed 10 years ago
Rebased.
Any thoughts, @nolta @ziotom78? Admittedly, I haven't thought that much about whether a FITSFile
can get into a really screwed up state where there should be flag in FITSFile
that indicates this. However, we have to change something. The current behavior is not the intended behavior, and the intended behavior is not good either (as illustrated by the try... catch
example above).
I agree with @kbarbary's point of view: the persistent status variable was probably implemented to imitate the way C code using CFITSIO is usually written. But Julia supports exceptions, and IMHO this is probably the cleanest and sanest thing to do.
(Moreover, this would make FITSIO.jl behave the same as the majority of Julia libraries, where the error status is not persistent. This would follow the POLA.)
Yeah, this seems reasonable.
This removes the
status
field fromFITSFile
, instead makingstatus
a local variable in each function. In each function, an appropriate error is raised ifstatus != 0
, so there should be no need to keep a non-zero status in aFITSFile
instance.Here is an example of why keeping a non-zero status in
FITSFile
, as is the existing intended behavior (suppose the keyword "EXTNAME" does not exist in the CHDU):Even though we're catching the error raised by
fits_read_keyword
,f.status
was set to 202 anyway. When we get tofits_movabs_hdu(f, i)
, it returns immediately becausef.status
is nonzero, and returns the error message associated with code 202.