improve possible VM errors

pull/1/head
yann300 7 years ago
parent e0208f1151
commit f2c47edb4e
  1. 21
      src/app/execution/txExecution.js

@ -38,6 +38,15 @@ module.exports = {
* @return {Object} - { error: true/false, message: DOMNode }
*/
checkVMError: function (txResult) {
var errorCode = {
OUT_OF_GAS: 'out of gas',
STACK_UNDERFLOW: 'stack underflow',
STACK_OVERFLOW: 'stack overflow',
INVALID_JUMP: 'invalid JUMP',
INVALID_OPCODE: 'invalid opcode',
REVERT: 'revert',
STATIC_STATE_CHANGE: 'static state change'
}
var ret = {
error: false,
message: ''
@ -47,14 +56,20 @@ module.exports = {
}
var error = `VM error: ${txResult.result.vm.exceptionError}.\n`
var msg
if (txResult.result.vm.exceptionError === 'invalid opcode') {
if (txResult.result.vm.exceptionError === errorCode.INVALID_OPCODE) {
msg = `\tThe constructor should be payable if you send value.\n\tThe execution might have thrown.\n`
ret.error = true
} else if (txResult.result.vm.exceptionError === 'out of gas') {
} else if (txResult.result.vm.exceptionError === errorCode.OUT_OF_GAS) {
msg = `\tThe transaction ran out of gas. Please increase the Gas Limit.\n`
ret.error = true
} else if (txResult.result.vm.exceptionError === errorCode.REVERT) {
msg = `\tThe transaction has been reverted to the initial state.\n`
ret.error = true
} else if (txResult.result.vm.exceptionError === errorCode.STATIC_STATE_CHANGE) {
msg = `\tState changes is not allowed in Static Call context\n`
ret.error = true
}
ret.message = `${error}${msg}\tDebug the transaction to get more information.`
ret.message = `${error}${txResult.result.vm.exceptionError}${msg}\tDebug the transaction to get more information.`
return ret
}
}

Loading…
Cancel
Save