ejeschke / ginga

The Ginga astronomical FITS file viewer
BSD 3-Clause "New" or "Revised" License
122 stars 77 forks source link

Ungraceful exit when FITS file not found #66

Closed pllim closed 9 years ago

pllim commented 9 years ago

Currently, when user attempts to open a FITS image and then press Cancel, the GUI exits ungracefully as follows:

$ python example2_qt.py
No handlers could be found for logger "example2"
Traceback (most recent call last):
  File "example2_qt.py", line 156, in open_file
    self.load_file(fileName)
  File "example2_qt.py", line 144, in load_file
    image.load_file(filepath)
  File ".../lib/python2.7/site-packages/ginga-2.1.20141220052723-py2.7.egg/ginga/AstroImage.py", line 97, in load_file
    naxispath=naxispath)
  File ".../lib/python2.7/site-packages/ginga-2.1.20141220052723-py2.7.egg/ginga/util/io_fits.py", line 124, in load_file
    fits_f = pyfits.open(filepath, 'readonly')
  File ".../lib/python2.7/site-packages/astropy/io/fits/hdu/hdulist.py", line 121, in fitsopen
    raise ValueError('Empty filename: %s' % repr(name))
ValueError: Empty filename: u''

I was expecting the GUI to still be up and running, instead of crashing like this.

pllim commented 9 years ago

Might just be that the example needs polishing.

ejeschke commented 9 years ago

@pllim, thank you! Bug fixed in master.