Skip to content

Commit

Permalink
Terminate VM execution and throw original error on programmatic/non-V…
Browse files Browse the repository at this point in the history
…M-internal errors
  • Loading branch information
holgerd77 committed Jul 11, 2018
1 parent 4ecae8a commit 9b1a0d0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/exceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const ERROR = {

function VmError (error) {
this.error = error
this.errorType = 'VmError'
}

module.exports = {
Expand Down
8 changes: 6 additions & 2 deletions lib/runCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,12 @@ module.exports = function (opts, cb) {
// run the opcode
var result = opFn.apply(null, args)
} catch (e) {
cb(e)
return
if (e.errorType && e.errorType === 'VmError') {
cb(e)
return
} else {
throw e
}
}

// save result to the stack
Expand Down

0 comments on commit 9b1a0d0

Please sign in to comment.