throw error for invalid strings

This commit is contained in:
Ryan X. Charles 2014-09-01 20:03:22 -07:00
parent eaaf8aade3
commit 8a3d71b596
1 changed files with 4 additions and 1 deletions

View File

@ -28,7 +28,10 @@ Opcode.prototype.toNumber = function() {
};
Opcode.prototype.fromString = function(str) {
this.num = Opcode.map[str];
var num = Opcode.map[str];
if (typeof num === 'undefined')
throw new Error('Invalid opcodestr');
this.num = num;
return this;
};