mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Clean up user rejection error message
This commit is contained in:
parent
e447438504
commit
62dc6e20eb
@ -111,6 +111,15 @@ class TransactionController extends EventEmitter {
|
|||||||
this.txStateManager.wipeTransactions(address)
|
this.txStateManager.wipeTransactions(address)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns error without stack trace for better UI display
|
||||||
|
@param {Error} err - error which stack will be cleaned
|
||||||
|
*/
|
||||||
|
cleanErrorStack(err){
|
||||||
|
err.stack = err.name + ': ' + err.message
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
add a new unapproved transaction to the pipeline
|
add a new unapproved transaction to the pipeline
|
||||||
|
|
||||||
@ -118,6 +127,8 @@ class TransactionController extends EventEmitter {
|
|||||||
@param txParams {object} - txParams for the transaction
|
@param txParams {object} - txParams for the transaction
|
||||||
@param opts {object} - with the key origin to put the origin on the txMeta
|
@param opts {object} - with the key origin to put the origin on the txMeta
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
async newUnapprovedTransaction (txParams, opts = {}) {
|
async newUnapprovedTransaction (txParams, opts = {}) {
|
||||||
log.debug(`MetaMaskController newUnapprovedTransaction ${JSON.stringify(txParams)}`)
|
log.debug(`MetaMaskController newUnapprovedTransaction ${JSON.stringify(txParams)}`)
|
||||||
const initialTxMeta = await this.addUnapprovedTransaction(txParams)
|
const initialTxMeta = await this.addUnapprovedTransaction(txParams)
|
||||||
@ -130,11 +141,11 @@ class TransactionController extends EventEmitter {
|
|||||||
case 'submitted':
|
case 'submitted':
|
||||||
return resolve(finishedTxMeta.hash)
|
return resolve(finishedTxMeta.hash)
|
||||||
case 'rejected':
|
case 'rejected':
|
||||||
return reject(new Error('MetaMask Tx Signature: User denied transaction signature.'))
|
return reject(this.cleanErrorStack(new Error('MetaMask Tx Signature: User denied transaction signature.')))
|
||||||
case 'failed':
|
case 'failed':
|
||||||
return reject(new Error(finishedTxMeta.err.message))
|
return reject(this.cleanErrorStack(new Error(finishedTxMeta.err.message)))
|
||||||
default:
|
default:
|
||||||
return reject(new Error(`MetaMask Tx Signature: Unknown problem: ${JSON.stringify(finishedTxMeta.txParams)}`))
|
return reject(this.cleanErrorStack(`MetaMask Tx Signature: Unknown problem: ${JSON.stringify(finishedTxMeta.txParams)}`))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user