Skip to content

Commit 5427ac7

Browse files
committed
Tools(extract): log tokenizer error (#113)
1 parent 9d16c3c commit 5427ac7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/qwik-speak/tools/core/parser.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,18 @@ export function parseSequenceExpressions(code: string, alias: string): CallExpre
385385

386386
const indexes = findIndexes(code, alias);
387387

388+
let tokens: Token[] = [];
388389
for (const i of indexes) {
389-
const tokens = tokenize(code, i);
390+
try {
391+
tokens = tokenize(code, i);
392+
} catch (ex: any) {
393+
// Report tokenizer
394+
console.error(ex);
395+
console.error('\n\x1b[31mQwik Speak Tokenizer error\x1b[0m\n%s',
396+
code.substring(i, i + 100) + ' [...]' +
397+
'\n');
398+
}
399+
390400
if (tokens.length > 0) {
391401
try {
392402
const callExpression = parse(tokens, code, alias);

0 commit comments

Comments
 (0)