Skip to content

Commit

Permalink
Better runtime error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Bell committed Apr 27, 2012
1 parent da75f33 commit 2a84015
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/cpu.js
Expand Up @@ -272,8 +272,10 @@ CPU.prototype = {

// Fetch the instruction
insn = this.nextInstruction();
if(root.OPCODES[insn.opcode] === undefined)
if(root.OPCODES[insn.opcode] === undefined) {
this.stop();
throw new Error('Encountered invalid opcode 0x' + insn.opcode.toString(16));
}

this.cycle += (root.OPCODES[insn.opcode].cost - 1) || 0;

Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "dcpu16",
"description": "An assembler and a vm for the DCPU-16 CPU from Notch's new game, 0x10c.",
"version": "0.2.19",
"version": "0.2.20",
"engines": {
"node": "*"
},
Expand Down

0 comments on commit 2a84015

Please sign in to comment.