try to give context if jsonc parsing fails
This commit is contained in:
parent
e471e050ad
commit
45488de06f
1 changed files with 8 additions and 2 deletions
10
ox/jsonc.py
10
ox/jsonc.py
|
@ -11,5 +11,11 @@ def load(f):
|
||||||
return loads(f.read())
|
return loads(f.read())
|
||||||
|
|
||||||
def loads(source):
|
def loads(source):
|
||||||
return json.loads(minify(source))
|
try:
|
||||||
|
minified = minify(source)
|
||||||
|
return json.loads(minified)
|
||||||
|
except json.JSONDecodeError, e:
|
||||||
|
s = minified.split('\n')
|
||||||
|
context = s[e.lineno-1][max(0, e.colno-1):e.colno+30]
|
||||||
|
msg = e.msg + ' at ' + context
|
||||||
|
raise json.JSONDecodeError(msg, minified, e.pos)
|
||||||
|
|
Loading…
Reference in a new issue