Adapt bf and chef to error handling

This commit is contained in:
Nilay Majorwar
2022-01-22 15:44:05 +05:30
parent 0efd4c79ef
commit 22ee70948a
8 changed files with 46 additions and 42 deletions

View File

@@ -66,7 +66,7 @@ const parseArithmeticOp = (line: string): C.ChefArithmeticOp => {
)
return { code, ing: matches[2], bowlId };
throw new Error("Malformed instruction");
throw new SyntaxError("Malformed instruction");
};
/** Assert that a line matches the given regex and return matches */
@@ -98,7 +98,7 @@ export const parseIngredientItem = (
// Parse next word as measurement unit
const measure = parseMeasure(words[words.length - 1]);
if (hasMeasureType && !measure) throw new Error("Invalid measure");
if (hasMeasureType && !measure) throw new SyntaxError("Invalid measure");
if (measure) words.pop();
// Parse rest of word as name of ingredient