Changeset dcb91cf in sasview for src/sas/sascalc/dataloader/loader.py
- Timestamp:
- Aug 21, 2017 10:16:13 AM (7 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 7b15990
- Parents:
- 44daa56
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/loader.py
r3a81cd9 rdcb91cf 69 69 readers if no reader was registered for the file's extension. 70 70 """ 71 # Gets set to a string if the file has an associated reader that fails 72 msg_from_reader = None 71 73 try: 72 74 return super(Registry, self).load(path, format=format) 73 75 except NoKnownLoaderException as nkl_e: 74 pass # try the ASCII reader76 pass # Try the ASCII reader 75 77 except FileContentsException as fc_exc: 76 # File has an associated reader but it failed 77 raise RuntimeError(fc_exc.message) 78 # File has an associated reader but it failed. 79 # Save the error message to display later, but try the 3 default loaders 80 msg_from_reader = fc_exc.message 78 81 except Exception: 79 82 pass 80 83 81 # File has no associated reader - try the ASCII reader 84 # File has no associated reader, or the associated reader failed. 85 # Try the ASCII reader 82 86 try: 83 87 ascii_loader = ascii_reader.Reader() … … 86 90 pass # Loader specific error to try the cansas XML reader 87 91 except FileContentsException as e: 88 raise RuntimeError(e.message) 92 if msg_from_reader is None: 93 raise RuntimeError(e.message) 89 94 90 95 # ASCII reader failed - try CanSAS xML reader … … 95 100 pass # Loader specific error to try the NXcanSAS reader 96 101 except FileContentsException as e: 97 raise RuntimeError(e.message) 98 except Exception as csr: 102 if msg_from_reader is None: 103 raise RuntimeError(e.message) 104 except Exception: 99 105 pass 100 106 … … 106 112 logging.error("No default loader can load the data") 107 113 # No known reader available. Give up and throw an error 108 msg = "\n\tUnknown data format: %s.\n\tThe file is not a " % path 109 msg += "known format that can be loaded by SasView.\n" 110 raise NoKnownLoaderException(msg) 114 if msg_from_reader is None: 115 msg = "\nUnknown data format: {}.\nThe file is not a ".format(path) 116 msg += "known format that can be loaded by SasView.\n" 117 raise NoKnownLoaderException(msg) 118 else: 119 # Associated reader and default readers all failed. 120 # Show error message from associated reader 121 raise RuntimeError(msg_from_reader) 111 122 except FileContentsException as e: 112 raise RuntimeError(e.message) 123 err_msg = msg_from_reader if msg_from_reader is not None else e.message 124 raise RuntimeError(err_msg) 113 125 114 126 def find_plugins(self, dir):
Note: See TracChangeset
for help on using the changeset viewer.