Skip to content

Commit 6bd8d8f

Browse files
committed
More helpful exception on negative line/col
1 parent 08a7d07 commit 6bd8d8f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

sourcemap/decoder.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,21 @@ def decode(self, source):
155155
except IndexError:
156156
raise SourceMapDecodeError
157157

158-
# lol for now
159158
try:
160159
assert dst_line >= 0
161160
assert dst_col >= 0
162161
assert src_line >= 0
163162
assert src_col >= 0
164163
except AssertionError:
165-
raise SourceMapDecodeError
164+
raise SourceMapDecodeError(
165+
"Segment %s has negative components:\n"
166+
" Source file: %s\n"
167+
" Source line: %s\n"
168+
" Source column: %s\n"
169+
" Mapped line: %s\n"
170+
" Mapped column: %s"
171+
% (segment, src, src_line, src_col, dst_line, dst_col)
172+
)
166173

167174
token = Token(dst_line, dst_col, src, src_line, src_col, name)
168175
tokens.append(token)

0 commit comments

Comments
 (0)