Skip to content

Commit

Permalink
Merge pull request #8 from SasView/loader_error_handling
Browse files Browse the repository at this point in the history
Improve loading error handling
  • Loading branch information
rozyczko committed May 19, 2016
2 parents 9194009 + faa3ae7 commit c9dc8c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/sas/sascalc/dataloader/readers/cansas_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ def read(self, xml_file):
return_value = self._final_cleanup(return_value)
output.append(return_value)
else:
output.append("Invalid XML at: {0}".format(\
self.find_invalid_xml()))
raise RuntimeError, "Invalid XML at: {0}".format(\
self.find_invalid_xml())
except:
# If the file does not match the schema, raise this error
raise RuntimeError, "%s cannot be read" % xml_file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,14 @@ def _process_data_and_errors(self, item, p_file, output, message):
error message to be sure user knows the issue.
"""
data_error = False
for error_data in item.errors:
if hasattr(item, 'errors'):
for error_data in item.errors:
data_error = True
message += "\tError: {0}\n".format(error_data)
else:
logging.error("Loader returned an invalid object:\n %s" % str(item))
data_error = True
message += "\tError: {0}\n".format(error_data)

data = self.parent.create_gui_data(item, p_file)
output[data.id] = data
return output, message, data_error
Expand Down Expand Up @@ -202,6 +207,7 @@ def get_data(self, path, format=None):
output,
error_message)
except:
logging.error(sys.exc_value)
any_error = True
if any_error or error_message != "":
if error_message == "":
Expand Down

0 comments on commit c9dc8c9

Please sign in to comment.