Skip to content

Commit

Permalink
Merge pull request #591 from IanCa/develop
Browse files Browse the repository at this point in the history
Add better load_schema_version error
  • Loading branch information
VisLab authored Feb 4, 2023
2 parents 94f467f + a24ca76 commit 48f2a92
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 8 additions & 7 deletions hed/errors/error_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,16 +395,17 @@ def get_exception_issue_string(issues, title=None):
str: A str containing printable version of the issues or ''.
"""

issue_str = ''
if issues:
translated_messages = []
issue_list = []
for issue in issues:
if isinstance(issue, str):
translated_messages.append(f"ERROR: {issue}.")
else:
translated_messages.append(f"ERROR: {issue[1]}.\n Source Line: {issue[0]}")
issue_str += '\n' + '\n'.join(translated_messages)
this_str = f"{issue['message']}"
if 'code' in issue:
this_str = f"{issue['code']}:" + this_str
if 'line_number' in issue:
this_str = this_str + f"\n\tLine number {issue['line_number']}: {issue.get('line', '')} "
issue_list.append(this_str)
issue_str += '\n' + '\n'.join(issue_list)
if title:
issue_str = title + '\n' + issue_str
return issue_str
Expand Down
2 changes: 2 additions & 0 deletions hed/schema/hed_schema_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ def _load_schema_version(xml_version=None, xml_folder=None):
if e.error_type == HedExceptions.FILE_NOT_FOUND:
hed_cache.cache_xml_versions()
final_hed_xml_file = hed_cache.get_hed_version_path(xml_version, library_name, xml_folder)
if not final_hed_xml_file:
raise HedFileError(HedExceptions.FILE_NOT_FOUND, f"HED version '{xml_version}' not found in cache: {hed_cache.get_cache_directory()}", filename=xml_folder)
hed_schema = load_schema(final_hed_xml_file)
else:
raise e
Expand Down

0 comments on commit 48f2a92

Please sign in to comment.