Skip to content

Commit

Permalink
2.6.5.1
Browse files Browse the repository at this point in the history
Improve the error message when attempting to parse a non-loop text block as a loop.
  • Loading branch information
jonwedell authored Mar 31, 2020
2 parents c846256 + 025a859 commit 64a2dbc
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pynmrstar.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def _build_extension():
_API_URL = "http://webapi.bmrb.wisc.edu/v2"
_SCHEMA_URL = 'https://raw.githubusercontent.com/uwbmrb/nmr-star-dictionary/master/xlschem_ann.csv'
_WHITESPACE = " \t\n\v"
__version__ = "2.6.5"
__version__ = "2.6.5.1"


#############################################
Expand Down Expand Up @@ -3056,7 +3056,13 @@ def __init__(self, **kwargs):
" _internal.use internal " + star_buffer.read() +
" save_")
parser = _Parser(entry_to_parse_into=tmp_entry)
parser.parse(star_buffer.read(), source=self.source)
try:
parser.parse(star_buffer.read(), source=self.source)
except ValueError as err:
if 'internaluseyoushouldntseethis' in str(err):
raise ValueError("Invalid loop. Loops must start with the 'loop_' keyword.", err.args[1])
else:
raise err

# Check that there was only one loop here
if len(tmp_entry[0].loops) > 1:
Expand Down

0 comments on commit 64a2dbc

Please sign in to comment.