From f2c47edb4e8fd81b655bf6e8d132344a3dadcf67 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 16 Oct 2017 14:17:39 +0200 Subject: [PATCH] improve possible VM errors --- src/app/execution/txExecution.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/app/execution/txExecution.js b/src/app/execution/txExecution.js index c9293b2d4d..908fd82350 100644 --- a/src/app/execution/txExecution.js +++ b/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 } }