Skip to content

Commit

Permalink
feat(normalize): catch and print TOML parse errors
Browse files Browse the repository at this point in the history
  • Loading branch information
themightychris committed Jan 8, 2022
1 parent 938910c commit 3906c3b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions backend/commands/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,18 @@ exports.handler = async function query({
}

// loop through all records and re-upsert
for await (const record of sheet.query()) {
logger.info(`rewriting ${sheetName}/${record[Symbol.for('gitsheets-path')]}`);
await sheet.upsert(record);
try {
for await (const record of sheet.query()) {
logger.info(`rewriting ${sheetName}/${record[Symbol.for('gitsheets-path')]}`);
await sheet.upsert(record);
}
} catch (err) {
if (err.constructor.name == 'TomlError') {
logger.error(`failed to parse ${path.join(root, prefix, err.file)}\n${err.message}`);
process.exit(1);
}

throw err;
}
}

Expand Down

0 comments on commit 3906c3b

Please sign in to comment.