Move some calls into the try block

This commit is contained in:
Asger F
2024-11-20 11:12:37 +01:00
parent d05cdf49ec
commit b90cfb670b

View File

@@ -41,16 +41,15 @@ export async function readJsonlFile<T>(
}
});
stream.on("end", async () => {
if (buffer.trim().length > 0) {
try {
try {
if (buffer.trim().length > 0) {
await handler(JSON.parse(buffer));
} catch (e) {
reject(e);
return;
}
void logger?.log(`Finished parsing ${path}`);
resolve();
} catch (e) {
reject(e);
}
void logger?.log(`Finished parsing ${path}`);
resolve();
});
stream.on("error", reject);
});