-
Notifications
You must be signed in to change notification settings - Fork 181
Closed
Description
Note the following IPython session using the 1.0 version of graphql-core
, where I feed the parser a simple empty string, and rather than getting a parse error, I get an unfriendly Python IndexError instead.
In [1]: from graphql.language.parser import parse
In [2]: parse('')
---------------------------------------------------------------------------
IndexError
Traceback (most recent call last)
<ipython-input> in <module>()
----> 1 parse('')
<omitted>/site-packages/graphql/language/parser.pyc in parse(source, **kwargs)
19
20 parser = Parser(source_obj, options)
---> 21 return parse_document(parser)
22
23
<omitted>/site-packages/graphql/language/parser.pyc in parse_document(parser)
188 definitions = []
189 while True:
--> 190 definitions.append(parse_definition(parser))
191
192 if skip(parser, TokenKind.EOF):
<omitted>/site-packages/graphql/language/parser.pyc in parse_definition(parser)
213 return parse_type_system_definition(parser)
214
--> 215 raise unexpected(parser)
216
217
<omitted>/site-packages/graphql/language/parser.pyc in unexpected(parser, at_token)
143 parser.source,
144 token.start,
--> 145 u'Unexpected {}'.format(get_token_desc(token))
146 )
147
<omitted>/site-packages/graphql/error/syntax_error.pyc in __init__(self, source, position, description)
15 location.column,
16 description,
---> 17 highlight_source_at_location(source, location),
18 ),
19 source=source,
<omitted>/site-packages/graphql/error/syntax_error.pyc in highlight_source_at_location(source, location)
30 if line >= 2:
31 result += format(line - 1, lines[line - 2])
---> 32 result += format(line, lines[line - 1])
33 result += ' ' * (1 + pad_len + location.column) + '^\n'
34 if line < len(lines):
IndexError: list index out of range
Metadata
Metadata
Assignees
Labels
No labels