Skip to content

Commit 51e9263

Browse files
committed
Check/report negative positions individually
1 parent 82b9769 commit 51e9263

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

sourcemap/decoder.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -170,21 +170,13 @@ def decode(self, source):
170170
% (segment, parse)
171171
)
172172

173-
try:
174-
assert dst_line >= 0
175-
assert dst_col >= 0
176-
assert src_line >= 0
177-
assert src_col >= 0
178-
except AssertionError:
179-
raise SourceMapDecodeError(
180-
"Segment %s has negative components:\n"
181-
" Source file: %s\n"
182-
" Source line: %s\n"
183-
" Source column: %s\n"
184-
" Mapped line: %s\n"
185-
" Mapped column: %s"
186-
% (segment, src, src_line, src_col, dst_line, dst_col)
187-
)
173+
locs = locals()
174+
for var in 'dst_line', 'dst_col', 'src_line', 'src_col':
175+
if locs[var] < 0:
176+
raise SourceMapDecodeError(
177+
"Segment %s has negative %s (%d), in file %s"
178+
% (segment, var, locs[var], src)
179+
)
188180

189181
token = Token(dst_line, dst_col, src, src_line, src_col, name)
190182
tokens.append(token)

0 commit comments

Comments
 (0)