Skip to content

Commit cbf2c73

Browse files
committed
Add debug URL to all errors
1 parent a9909e4 commit cbf2c73

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/index.ts

+13-4
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@ function lexer(str: string) {
186186
let pattern = "";
187187

188188
if (chars[i] === "?") {
189-
throw new TypeError(`Pattern cannot start with "?" at ${i}`);
189+
throw new TypeError(
190+
`Pattern cannot start with "?" at ${i}: ${DEBUG_URL}`,
191+
);
190192
}
191193

192194
while (i < chars.length) {
@@ -204,15 +206,22 @@ function lexer(str: string) {
204206
} else if (chars[i] === "(") {
205207
count++;
206208
if (chars[i + 1] !== "?") {
207-
throw new TypeError(`Capturing groups are not allowed at ${i}`);
209+
throw new TypeError(
210+
`Capturing groups are not allowed at ${i}: ${DEBUG_URL}`,
211+
);
208212
}
209213
}
210214

211215
pattern += chars[i++];
212216
}
213217

214-
if (count) throw new TypeError(`Unbalanced pattern at ${pos}`);
215-
if (!pattern) throw new TypeError(`Missing pattern at ${pos}`);
218+
if (count) {
219+
throw new TypeError(`Unbalanced pattern at ${pos}: ${DEBUG_URL}`);
220+
}
221+
222+
if (!pattern) {
223+
throw new TypeError(`Missing pattern at ${pos}: ${DEBUG_URL}`);
224+
}
216225

217226
tokens.push({ type: "PATTERN", index: i, value: pattern });
218227
continue;

0 commit comments

Comments
 (0)