remix-lib/src/execution/txExecution.js
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: ''
    }
    if (!txResult.result.vm.exceptionError) {
      return ret
    }
    var exceptionError = txResult.result.vm.exceptionError.error || ''
    var error = `VM error: ${exceptionError}.\n`
    var msg
    if (exceptionError === errorCode.INVALID_OPCODE) {
      msg = `\t\n\tThe execution might have thrown.\n`
      ret.error = true
    } else if (exceptionError === errorCode.OUT_OF_GAS) {
      msg = `\tThe transaction ran out of gas. Please increase the Gas Limit.\n`
      ret.error = true
    } else if (exceptionError === errorCode.REVERT) {
      var returnData = txResult.result.vm.return
      // It is the hash of Error(string)
      if (returnData && (returnData.slice(0, 4).toString('hex') === '08c379a0')) {
        var abiCoder = new ethers.utils.AbiCoder()
        var reason = abiCoder.decode(['string'], returnData.slice(4))[0]
        msg = `\tThe transaction has been reverted to the initial state.\nReason provided by the contract: "${reason}".`
      } else {
        msg = `\tThe transaction has been reverted to the initial state.\nNote: The called function should be payable if you send value and the value you send should be less than your current balance.`
      }
      ret.error = true
    } else if (exceptionError === errorCode.STATIC_STATE_CHANGE) {
      msg = `\tState changes is not allowed in Static Call context\n`
      ret.error = true
    }
    ret.message = `${error}${exceptionError}${msg}\tDebug the transaction to get more information.`
    return ret
  }
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: ''
    }
    if (!txResult.result.vm.exceptionError) {
      return ret
    }
    var exceptionError = txResult.result.vm.exceptionError.error || ''
    var error = `VM error: ${exceptionError}.\n`
    var msg
    if (exceptionError === errorCode.INVALID_OPCODE) {
      msg = `\t\n\tThe execution might have thrown.\n`
      ret.error = true
    } else if (exceptionError === errorCode.OUT_OF_GAS) {
      msg = `\tThe transaction ran out of gas. Please increase the Gas Limit.\n`
      ret.error = true
    } else if (exceptionError === errorCode.REVERT) {
      var returnData = txResult.result.vm.return
      // It is the hash of Error(string)
      if (returnData && (returnData.slice(0, 4).toString('hex') === '08c379a0')) {
        var abiCoder = new ethers.utils.AbiCoder()
        var reason = abiCoder.decode(['string'], returnData.slice(4))[0]
        msg = `\tThe transaction has been reverted to the initial state.\nReason provided by the contract: "${reason}".`
      } else {
        msg = `\tThe transaction has been reverted to the initial state.\nNote: The called function should be payable if you send value and the value you send should be less than your current balance.`
      }
      ret.error = true
    } else if (exceptionError === errorCode.STATIC_STATE_CHANGE) {
      msg = `\tState changes is not allowed in Static Call context\n`
      ret.error = true
    }
    ret.message = `${error}${exceptionError}${msg}\tDebug the transaction to get more information.`
    return ret
  }
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 : '' } if ( ! txResult . result . vm . exceptionError ) { return ret } var exceptionError = txResult . result . vm . exceptionError . error || '' var error = ` ${ exceptionError } \n ` var msg if ( exceptionError === errorCode . INVALID_OPCODE ) { msg = ` \t \n \t \n ` ret . error = true } else if ( exceptionError === errorCode . OUT_OF_GAS ) { msg = ` \t \n ` ret . error = true } else if ( exceptionError === errorCode . REVERT ) { var returnData = txResult . result . vm . return // It is the hash of Error(string) if ( returnData && ( returnData . slice ( 0 , 4 ) . toString ( 'hex' ) === '08c379a0' ) ) { var abiCoder = new ethers . utils . AbiCoder ( ) var reason = abiCoder . decode ( [ 'string' ] , returnData . slice ( 4 ) ) [ 0 ] msg = ` \t \n ${ reason } ` } else { msg = ` \t \n ` } ret . error = true } else if ( exceptionError === errorCode . STATIC_STATE_CHANGE ) { msg = ` \t \n ` ret . error = true } ret . message = ` ${ error } ${ exceptionError } ${ msg } \t ` return ret }
check if the vm has errored

@param {Object} txResult    - the value returned by the vm
@return {Object} -  { error: true/false, message: DOMNode }
check if the vm has errored