2
2
3
3
from six import unichr
4
4
5
- from .error import LanguageError
5
+ from .. error import GraphQLSyntaxError
6
6
7
7
__all__ = ['Token' , 'Lexer' , 'TokenKind' ,
8
8
'get_token_desc' , 'get_token_kind_desc' ]
@@ -156,7 +156,7 @@ def read_token(source, from_position):
156
156
code = char_code_at (body , position )
157
157
158
158
if code < 0x0020 and code not in (0x0009 , 0x000A , 0x000D ):
159
- raise LanguageError (
159
+ raise GraphQLSyntaxError (
160
160
source , position ,
161
161
u'Invalid character {}.' .format (print_char_code (code ))
162
162
)
@@ -179,7 +179,7 @@ def read_token(source, from_position):
179
179
elif code == 34 : # "
180
180
return read_string (source , position )
181
181
182
- raise LanguageError (
182
+ raise GraphQLSyntaxError (
183
183
source , position ,
184
184
u'Unexpected character {}.' .format (print_char_code (code )))
185
185
@@ -241,7 +241,7 @@ def read_number(source, start, first_code):
241
241
code = char_code_at (body , position )
242
242
243
243
if code is not None and 48 <= code <= 57 :
244
- raise LanguageError (
244
+ raise GraphQLSyntaxError (
245
245
source ,
246
246
position ,
247
247
u'Invalid number, unexpected digit after 0: {}.' .format (print_char_code (code ))
@@ -291,7 +291,7 @@ def read_digits(source, start, first_code):
291
291
292
292
return position
293
293
294
- raise LanguageError (
294
+ raise GraphQLSyntaxError (
295
295
source ,
296
296
position ,
297
297
u'Invalid number, expected digit but got: {}.' .format (print_char_code (code ))
@@ -338,7 +338,7 @@ def read_string(source, start):
338
338
break
339
339
340
340
if code < 0x0020 and code != 0x0009 :
341
- raise LanguageError (
341
+ raise GraphQLSyntaxError (
342
342
source ,
343
343
position ,
344
344
u'Invalid character within String: {}.' .format (print_char_code (code ))
@@ -362,15 +362,15 @@ def read_string(source, start):
362
362
)
363
363
364
364
if char_code < 0 :
365
- raise LanguageError (
365
+ raise GraphQLSyntaxError (
366
366
source , position ,
367
367
u'Invalid character escape sequence: \\ u{}.' .format (body [position + 1 : position + 5 ])
368
368
)
369
369
370
370
append (unichr (char_code ))
371
371
position += 4
372
372
else :
373
- raise LanguageError (
373
+ raise GraphQLSyntaxError (
374
374
source , position ,
375
375
u'Invalid character escape sequence: \\ {}.' .format (unichr (code ))
376
376
)
@@ -379,7 +379,7 @@ def read_string(source, start):
379
379
chunk_start = position
380
380
381
381
if code != 34 : # Quote (")
382
- raise LanguageError (source , position , 'Unterminated string' )
382
+ raise GraphQLSyntaxError (source , position , 'Unterminated string' )
383
383
384
384
append (body [chunk_start :position ])
385
385
return Token (TokenKind .STRING , start , position + 1 , u'' .join (value ))
0 commit comments