From 2802623c4c45ab8836598108ecc811283ebbd3ed Mon Sep 17 00:00:00 2001 From: n loewen Date: Thu, 24 Aug 2023 16:33:33 +0100 Subject: [PATCH] assembler - Change error handling: Just quit, don't throw a JS error --- assembler.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/assembler.js b/assembler.js index 1c5e0a7..01074d3 100644 --- a/assembler.js +++ b/assembler.js @@ -110,8 +110,7 @@ function preparseSourceCode(source) { console.error(); console.error(`Error: Too many arguments`); console.error(` at line ${info.number}`); - console.error(); - throw new Error("Too many arguments"); + process.exit(); } } return info; @@ -240,8 +239,7 @@ function decodeInstructions(source) { console.error(''); console.error(`Error: Missing operand ${line.source}`); console.error(` at line ${line.number}`); - console.error(''); - throw new Error("Missing operand"); + process.exit(); } else { // It *is* one of the special optional-arg ops // So let's fill in the implicit operand with $00 @@ -320,8 +318,7 @@ function decodeInstructions(source) { console.error(); console.error(`Error: Undefined constant '${line.argument}'`); console.error(` at line ${line.number}`); - console.error(); - throw new Error('Undefined constant'); + process.exit(); } decodedArg = decodeNumericOp(constants[line.argument.substring(1)]); // substring(1) strips '>' }