22
33from six import unichr
44
5- from .error import LanguageError
5+ from .. error import GraphQLSyntaxError
66
77__all__ = ['Token' , 'Lexer' , 'TokenKind' ,
88 'get_token_desc' , 'get_token_kind_desc' ]
@@ -156,7 +156,7 @@ def read_token(source, from_position):
156156 code = char_code_at (body , position )
157157
158158 if code < 0x0020 and code not in (0x0009 , 0x000A , 0x000D ):
159- raise LanguageError (
159+ raise GraphQLSyntaxError (
160160 source , position ,
161161 u'Invalid character {}.' .format (print_char_code (code ))
162162 )
@@ -179,7 +179,7 @@ def read_token(source, from_position):
179179 elif code == 34 : # "
180180 return read_string (source , position )
181181
182- raise LanguageError (
182+ raise GraphQLSyntaxError (
183183 source , position ,
184184 u'Unexpected character {}.' .format (print_char_code (code )))
185185
@@ -241,7 +241,7 @@ def read_number(source, start, first_code):
241241 code = char_code_at (body , position )
242242
243243 if code is not None and 48 <= code <= 57 :
244- raise LanguageError (
244+ raise GraphQLSyntaxError (
245245 source ,
246246 position ,
247247 u'Invalid number, unexpected digit after 0: {}.' .format (print_char_code (code ))
@@ -291,7 +291,7 @@ def read_digits(source, start, first_code):
291291
292292 return position
293293
294- raise LanguageError (
294+ raise GraphQLSyntaxError (
295295 source ,
296296 position ,
297297 u'Invalid number, expected digit but got: {}.' .format (print_char_code (code ))
@@ -338,7 +338,7 @@ def read_string(source, start):
338338 break
339339
340340 if code < 0x0020 and code != 0x0009 :
341- raise LanguageError (
341+ raise GraphQLSyntaxError (
342342 source ,
343343 position ,
344344 u'Invalid character within String: {}.' .format (print_char_code (code ))
@@ -362,15 +362,15 @@ def read_string(source, start):
362362 )
363363
364364 if char_code < 0 :
365- raise LanguageError (
365+ raise GraphQLSyntaxError (
366366 source , position ,
367367 u'Invalid character escape sequence: \\ u{}.' .format (body [position + 1 : position + 5 ])
368368 )
369369
370370 append (unichr (char_code ))
371371 position += 4
372372 else :
373- raise LanguageError (
373+ raise GraphQLSyntaxError (
374374 source , position ,
375375 u'Invalid character escape sequence: \\ {}.' .format (unichr (code ))
376376 )
@@ -379,7 +379,7 @@ def read_string(source, start):
379379 chunk_start = position
380380
381381 if code != 34 : # Quote (")
382- raise LanguageError (source , position , 'Unterminated string' )
382+ raise GraphQLSyntaxError (source , position , 'Unterminated string' )
383383
384384 append (body [chunk_start :position ])
385385 return Token (TokenKind .STRING , start , position + 1 , u'' .join (value ))
0 commit comments