Skip to content

Commit 83daed1

Browse files
committed
☕ verbose message when parse errored
1 parent 78f7351 commit 83daed1

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

.scripts/gen-function/parse.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,11 @@ export function parse(content: string): Definition[] {
5858
} else {
5959
const line = content.substring(0, start + 1).split("\n").length;
6060
console.error(
61-
`Failed to parse function definition for ${fn} at line ${line}`,
61+
`Failed to parse function definition for '${fn}' at line ${line}:`,
6262
);
63+
console.error("----- block start -----");
64+
console.error(block);
65+
console.error("----- block end -----");
6366
}
6467
}
6568
return definitions;

.scripts/gen-option/parse.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function parse(content: string) {
2929

3030
const options: Option[] = [];
3131
const succeeds = new Set<number>();
32-
const errors: Array<{ name: string; start: number }> = [];
32+
const errors: Array<{ name: string; start: number; block: string }> = [];
3333
let last = -1;
3434
for (const match of content.matchAll(/\*'(\w+)'\*/g)) {
3535
const name = match[1];
@@ -45,17 +45,20 @@ export function parse(content: string) {
4545
succeeds.add(start);
4646
last = end;
4747
} else {
48-
errors.push({ name, start });
48+
errors.push({ name, start, block });
4949
}
5050
}
5151

5252
if (errors.length) {
53-
for (const { name, start } of errors) {
53+
for (const { name, start, block } of errors) {
5454
if (!succeeds.has(start)) {
5555
const line = content.substring(0, start + 1).split("\n").length;
5656
console.error(
57-
`Failed to parse option definition for ${name} at line ${line}`,
57+
`Failed to parse option definition for '${name}' at line ${line}:`,
5858
);
59+
console.error("----- block start -----");
60+
console.error(block);
61+
console.error("----- block end -----");
5962
}
6063
}
6164
}

0 commit comments

Comments
 (0)