Catch uncaught transaction errors

pull/2642/head^2
David Disu 3 years ago committed by Aniket
parent ff5b46c7cf
commit 7a8a9143f9
  1. 53
      apps/remix-ide/src/blockchain/blockchain.js

@ -617,30 +617,43 @@ export class Blockchain extends Plugin {
const timestamp = tx.timestamp const timestamp = tx.timestamp
this.event.trigger('initiatingTransaction', [timestamp, tx, payLoad]) this.event.trigger('initiatingTransaction', [timestamp, tx, payLoad])
this.txRunner.rawRun(tx, confirmationCb, continueCb, promptCb, try {
async (error, result) => { this.txRunner.rawRun(tx, confirmationCb, continueCb, promptCb,
if (error) return reject(error) async (error, result) => {
if (error) {
const isVM = this.executionContext.isVM() if (typeof (error) !== 'string') {
if (isVM && tx.useCall) { if (error.message) error = error.message
try { else {
result.transactionHash = await this.web3().eth.getHashFromTagBySimulator(timestamp) try { error = 'error: ' + JSON.stringify(error) } catch (e) { console.log(e) }
} catch (e) { }
console.log('unable to retrieve back the "call" hash', e) }
return reject(error)
} }
}
const eventName = (tx.useCall ? 'callExecuted' : 'transactionExecuted') const isVM = this.executionContext.isVM()
this.event.trigger(eventName, [error, tx.from, tx.to, tx.data, tx.useCall, result, timestamp, payLoad]) if (isVM && tx.useCall) {
try {
if (error && (typeof (error) !== 'string')) { result.transactionHash = await this.web3().eth.getHashFromTagBySimulator(timestamp)
if (error.message) error = error.message } catch (e) {
else { console.log('unable to retrieve back the "call" hash', e)
try { error = 'error: ' + JSON.stringify(error) } catch (e) { console.log(e) } }
} }
const eventName = (tx.useCall ? 'callExecuted' : 'transactionExecuted')
this.event.trigger(eventName, [error, tx.from, tx.to, tx.data, tx.useCall, result, timestamp, payLoad])
return resolve({ result, tx })
}
)
} catch (err) {
let error = err
if (error && (typeof (error) !== 'string')) {
if (error.message) error = error.message
else {
try { error = 'error: ' + JSON.stringify(error) } catch (e) { console.log(e) }
} }
return resolve({ result, tx })
} }
) return reject(error)
}
}) })
} }
try { try {

Loading…
Cancel
Save