alert vm error if any

pull/1/head
yann300 7 years ago
parent fa34ec91f8
commit 67ddb9c906
  1. 21
      src/app/tabs/run-tab.js

@ -273,8 +273,11 @@ function contractDropdown (appAPI, appEvents, instanceContainer) {
if (!error) { if (!error) {
txExecution.createContract(data, appAPI.udapp(), (error, txResult) => { txExecution.createContract(data, appAPI.udapp(), (error, txResult) => {
if (!error) { if (!error) {
var isVM = appAPI.executionContext().isVM()
if (isVM && alertVMErrorIfAny(txResult)) return
noInstancesText.style.display = 'none' 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)) instanceContainer.appendChild(appAPI.udapp().renderInstance(contract, address, selectContractNames.value))
} else { } else {
modalDialogCustom.alert(error) 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`<span> VM error: ${txResult.result.vm.exceptionError}</span>`
var msg
if (txResult.result.vm.exceptionError === 'invalid opcode') {
msg = yo`<ul><li>The constructor should be payable if you send it value.</li>
<li>The execution might have thrown.</li></ul>`
} else if (txResult.result.vm.exceptionError === 'out of gas') {
msg = yo`<div>The transaction ran out of gas. Please increase the Gas Limit.</div>`
}
modalDialogCustom.alert(yo`<div>${error} ${msg} Debug the transaction to get more information</div>`)
return error + msg
}
function loadFromAddress (appAPI) { function loadFromAddress (appAPI) {
noInstancesText.style.display = 'none' noInstancesText.style.display = 'none'
var contractNames = document.querySelector(`.${css.contractNames.classNames[0]}`) var contractNames = document.querySelector(`.${css.contractNames.classNames[0]}`)

Loading…
Cancel
Save