Improve Chef error messages

This commit is contained in:
Nilay Majorwar
2022-01-22 18:49:26 +05:30
parent 22ee70948a
commit 22939dabf5
2 changed files with 4 additions and 4 deletions

View File

@@ -66,13 +66,13 @@ const parseArithmeticOp = (line: string): C.ChefArithmeticOp => {
)
return { code, ing: matches[2], bowlId };
throw new SyntaxError("Malformed instruction");
throw new SyntaxError("Instruction has incorrect syntax");
};
/** Assert that a line matches the given regex and return matches */
const assertMatch = (line: string, regex: RegExp): RegExpMatchArray => {
const matches = line.match(regex);
if (!matches) throw new SyntaxError("Malformed instruction");
if (!matches) throw new SyntaxError("Unknown instruction");
return matches;
};