Skip to content

Commit

Permalink
handle exception in export plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed Dec 18, 2024
1 parent 504f25c commit bfdeb50
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions jdaviz/configs/default/plugins/export/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,12 @@ def _is_filename_changed(self, event):
def _update_subset_format_disabled(self):
new_items = []
if self.subset.selected is not None:
subset = self.app.get_subsets(self.subset.selected)
try:
subset = self.app.get_subsets(self.subset.selected)
except Exception:
# subset invalid message will already be set,
# no need to set valid/invalid formats.
return
if self.app._is_subset_spectral(subset[0]):
good_formats = ["ecsv"]
else:
Expand Down Expand Up @@ -333,16 +338,20 @@ def _set_subset_not_supported_msg(self, msg=None):
disable Export button until these are supported.
"""

if self.subset.selected is not None:
subset = self.app.get_subsets(self.subset.selected)
if self.subset.selected == '':
self.subset_invalid_msg = ''
elif self.app._is_subset_spectral(subset[0]):
self.subset_invalid_msg = ''
elif len(subset) > 1:
self.subset_invalid_msg = 'Export for composite subsets not yet supported.'
if self.subset.selected not in [None, '']:
try:
subset = self.app.get_subsets(self.subset.selected)
except Exception as e:
self.subset_invalid_msg = f"Export for subset not supported: {e}"
else:
self.subset_invalid_msg = ''
if self.subset.selected == '':
self.subset_invalid_msg = ''
elif self.app._is_subset_spectral(subset[0]):
self.subset_invalid_msg = ''
elif len(subset) > 1:
self.subset_invalid_msg = 'Export for composite subsets not yet supported.'
else:
self.subset_invalid_msg = ''
else: # no subset selected (can be '' instead of None if previous selection made)
self.subset_invalid_msg = ''

Expand Down

0 comments on commit bfdeb50

Please sign in to comment.