aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton <anton@chainsecurity.com>2018-05-28 23:57:45 +0800
committerAnton <anton@chainsecurity.com>2018-05-28 23:57:45 +0800
commit62dc6e20eb1f7188c6452519782e8ebe54c1c540 (patch)
tree094d7a23886953ff87003081e9071f5a877d7c4e
parente447438504d791f60e389c328970da7db2dbf4dc (diff)
downloadtangerine-wallet-browser-62dc6e20eb1f7188c6452519782e8ebe54c1c540.tar.gz
tangerine-wallet-browser-62dc6e20eb1f7188c6452519782e8ebe54c1c540.tar.zst
tangerine-wallet-browser-62dc6e20eb1f7188c6452519782e8ebe54c1c540.zip
Clean up user rejection error message
-rw-r--r--app/scripts/controllers/transactions/index.js17
1 files changed, 14 insertions, 3 deletions
diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js
index 541f1db73..586a80baf 100644
--- a/app/scripts/controllers/transactions/index.js
+++ b/app/scripts/controllers/transactions/index.js
@@ -112,12 +112,23 @@ class TransactionController extends EventEmitter {
}
/**
+ 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
@returns {Promise<string>} the hash of the transaction after being submitted to the network
@param txParams {object} - txParams for the transaction
@param opts {object} - with the key origin to put the origin on the txMeta
*/
+
+
async newUnapprovedTransaction (txParams, opts = {}) {
log.debug(`MetaMaskController newUnapprovedTransaction ${JSON.stringify(txParams)}`)
const initialTxMeta = await this.addUnapprovedTransaction(txParams)
@@ -130,11 +141,11 @@ class TransactionController extends EventEmitter {
case 'submitted':
return resolve(finishedTxMeta.hash)
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':
- return reject(new Error(finishedTxMeta.err.message))
+ return reject(this.cleanErrorStack(new Error(finishedTxMeta.err.message)))
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)}`))
}
})
})