Skip to content

Commit aed9d52

Browse files
committed
ensure all errors are exhausted and actually throw the error
1 parent 45d4c5e commit aed9d52

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

src/dictionary/parallel_parser.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,18 @@ export async function parseDictionary(source: string): Promise<Dictionary> {
9090
}
9191
continue;
9292
}
93-
if (errors.length === 0) {
94-
for (const [word, definition] of entries.entries()) {
95-
if (dictionary.has(word)) {
96-
errors.push(new ResultError(`duplicate Toki Pona word "${word}"`));
97-
break;
98-
} else {
99-
dictionary.set(word, definition);
100-
}
93+
for (const [word, definition] of entries.entries()) {
94+
if (dictionary.has(word)) {
95+
errors.push(new ResultError(`duplicate Toki Pona word "${word}"`));
96+
break;
97+
} else {
98+
dictionary.set(word, definition);
10199
}
102100
}
103101
}
104-
return dictionary;
102+
if (errors.length === 0) {
103+
return dictionary;
104+
} else {
105+
throw new AggregateError(errors);
106+
}
105107
}

0 commit comments

Comments
 (0)