From cb4ab121283e690506aa6bf17abb6fd5b8142107 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Wed, 11 Sep 2019 20:36:46 -0700 Subject: [PATCH] Improve error message for missing opcode --- modern/src/maki-interpreter/parser.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modern/src/maki-interpreter/parser.js b/modern/src/maki-interpreter/parser.js index d5c1abc5..669bbf91 100644 --- a/modern/src/maki-interpreter/parser.js +++ b/modern/src/maki-interpreter/parser.js @@ -12,8 +12,12 @@ const PRIMITIVE_TYPES = { // TODO: Don't depend upon COMMANDS function opcodeToArgType(opcode) { - const argType = COMMANDS[opcode].arg; - switch (argType) { + const command = COMMANDS[opcode]; + if (command == null) { + throw new Error(`Unknown opcode ${opcode}`); + } + + switch (command.arg) { case "func": case "line": return "COMMAND_OFFSET";