Skip to content

Commit

Permalink
Catch at least *some* errors out of ajv.
Browse files Browse the repository at this point in the history
Doesn't catch all of them, because even though AJV's strict mode is
documented to default to true, it also has a strictTypes setting which defaults
to 'log', meaning it will spew some messages to stderr (which currently bowtie
always marks as an uncaught error). Unclear yet precisely what to tweak.
  • Loading branch information
Julian committed Sep 17, 2022
1 parent df766fa commit 7820134
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions implementations/js-ajv/bowtie_ajv.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,22 @@ const cmds = {
run: (args) => {
console.assert(started, "Not started!");

const testCase = args.case;
const validate = ajv.compile(testCase.schema);
return {
seq: args.seq,
results: testCase.tests.map((test) => ({
valid: validate(test.instance),
})),
};
try {
const testCase = args.case;
const validate = ajv.compile(testCase.schema);
return {
seq: args.seq,
results: testCase.tests.map((test) => ({
valid: validate(test.instance),
})),
};
} catch (e) {
return {
errored: true,
seq: args.seq,
context: { error: e.toString() },
};
}
},

stop: (_) => {
Expand Down

0 comments on commit 7820134

Please sign in to comment.