diff --git a/hexrdgui/image_file_manager.py b/hexrdgui/image_file_manager.py index 50828a74a..6cfe79def 100644 --- a/hexrdgui/image_file_manager.py +++ b/hexrdgui/image_file_manager.py @@ -47,18 +47,10 @@ def load_dummy_images(self, initial=False): def load_images(self, detectors, file_names, options=None): HexrdConfig().imageseries_dict.clear() for name, f in zip(detectors, file_names): - try: - if isinstance(f, list): - f = f[0] - ims = self.open_file(f, options) - HexrdConfig().imageseries_dict[name] = ims - except (Exception, IOError): - exc_str = traceback.format_exc() - msg = f'ERROR - Could not read file: \n{exc_str}' - HexrdConfig().logger.critical(msg) - # Since this is a non-gui thread, we can't use QMessageBox - # here, or we will have a segmentation fault. - return + if isinstance(f, list): + f = f[0] + ims = self.open_file(f, options) + HexrdConfig().imageseries_dict[name] = ims # Save the path if it should be remembered if self.remember: @@ -85,7 +77,8 @@ def open_file(self, f, options=None): if ims_type not in registry: msg = ( '"dectris-compression" must be installed to load ' - 'eiger stream files' + 'eiger stream files.\n\n' + 'Try `pip install dectris-compression`' ) raise Exception(msg) diff --git a/hexrdgui/image_load_manager.py b/hexrdgui/image_load_manager.py index 84a8b46df..8c1341b44 100644 --- a/hexrdgui/image_load_manager.py +++ b/hexrdgui/image_load_manager.py @@ -170,6 +170,7 @@ def begin_processing(self, postprocess=False): worker.signals.progress.connect(progress_dialog.setValue) # On completion load imageseries nd close loading dialog worker.signals.result.connect(self.finish_processing_ims) + worker.signals.error.connect(self.on_process_ims_error) worker.signals.finished.connect(progress_dialog.accept) progress_dialog.exec() @@ -229,6 +230,12 @@ def finish_processing_ims(self): if self.transformed_images: HexrdConfig().deep_rerender_needed.emit() + def on_process_ims_error(self, error): + exctype, value, tb = error + msg = f'Failed to process imageseries.\n\n{value}' + QMessageBox.critical(None, 'Error', msg) + HexrdConfig().logger.critical(tb) + def get_dark_aggr_op(self, ims, idx): """ Returns a tuple of the form (function, frames), where func is the diff --git a/hexrdgui/simple_image_series_dialog.py b/hexrdgui/simple_image_series_dialog.py index a99f2d83e..5ebd5ffc1 100644 --- a/hexrdgui/simple_image_series_dialog.py +++ b/hexrdgui/simple_image_series_dialog.py @@ -235,7 +235,13 @@ def select_images(self): if selected_files: self.update_allowed = False self.reset_data() - self.load_image_data(selected_files) + + try: + self.load_image_data(selected_files) + except Exception as e: + QMessageBox.critical(self.ui, 'Failed to load files', str(e)) + raise + self.create_table() self.setup_gui() self.enable_read()