Skip to content

Commit

Permalink
Handle errors in async calls
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Aug 21, 2017
1 parent 5b3593e commit f4122b0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/runCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,17 @@ module.exports = function (opts, cb) {
// create a callback for async opFunc
if (opInfo.async) {
args.push(function (err, result) {
if (err) return cb(err)

// save result to the stack
if (result) {
// NOTE: Ensure that every stack item is padded to 256 bits.
// This should be done at every opcode in the future.
result = utils.setLengthLeft(result, 32)
runState.stack.push(result)
}
cb(err)

cb()
})
}

Expand Down

0 comments on commit f4122b0

Please sign in to comment.