From 67ddb9c906a7c0f1ffab9915ea4333abe8bd678b Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 17 Aug 2017 15:08:20 +0200 Subject: [PATCH] alert vm error if any --- src/app/tabs/run-tab.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/app/tabs/run-tab.js b/src/app/tabs/run-tab.js index 80d98b7f6c..b53391688a 100644 --- a/src/app/tabs/run-tab.js +++ b/src/app/tabs/run-tab.js @@ -273,8 +273,11 @@ function contractDropdown (appAPI, appEvents, instanceContainer) { if (!error) { txExecution.createContract(data, appAPI.udapp(), (error, txResult) => { if (!error) { + var isVM = appAPI.executionContext().isVM() + if (isVM && alertVMErrorIfAny(txResult)) return + noInstancesText.style.display = 'none' - var address = appAPI.executionContext().isVM() ? txResult.result.createdAddress : txResult.result.contractAddress + var address = isVM ? txResult.result.createdAddress : txResult.result.contractAddress instanceContainer.appendChild(appAPI.udapp().renderInstance(contract, address, selectContractNames.value)) } else { modalDialogCustom.alert(error) @@ -286,6 +289,22 @@ function contractDropdown (appAPI, appEvents, instanceContainer) { }) } + function alertVMErrorIfAny (txResult) { + if (!txResult.result.vm.exceptionError) { + return null + } + var error = yo` VM error: ${txResult.result.vm.exceptionError}` + var msg + if (txResult.result.vm.exceptionError === 'invalid opcode') { + msg = yo`` + } else if (txResult.result.vm.exceptionError === 'out of gas') { + msg = yo`
The transaction ran out of gas. Please increase the Gas Limit.
` + } + modalDialogCustom.alert(yo`
${error} ${msg} Debug the transaction to get more information
`) + return error + msg + } + function loadFromAddress (appAPI) { noInstancesText.style.display = 'none' var contractNames = document.querySelector(`.${css.contractNames.classNames[0]}`)