From 32dbf9958ea832b3f55f48e77e0c735a737057d1 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Wed, 11 Jan 2017 17:02:39 +0100 Subject: [PATCH] Better error log reporting & handling (#4128) --- js/src/api/contract/contract.js | 24 ++++++++++++++++++++--- js/src/redux/providers/personalActions.js | 7 +++++++ js/src/views/Dapps/dappsStore.js | 2 +- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/js/src/api/contract/contract.js b/js/src/api/contract/contract.js index 9c3b02b72..df134fbfd 100644 --- a/js/src/api/contract/contract.js +++ b/js/src/api/contract/contract.js @@ -248,18 +248,32 @@ export default class Contract { .call(callParams) .then((encoded) => func.decodeOutput(encoded)) .then((tokens) => tokens.map((token) => token.value)) - .then((returns) => returns.length === 1 ? returns[0] : returns); + .then((returns) => returns.length === 1 ? returns[0] : returns) + .catch((error) => { + console.warn(`${func.name}.call`, values, error); + throw error; + }); }; if (!func.constant) { func.postTransaction = (options, values = []) => { const _options = this._encodeOptions(func, this._addOptionsTo(options), values); - return this._api.parity.postTransaction(_options); + return this._api.parity + .postTransaction(_options) + .catch((error) => { + console.warn(`${func.name}.postTransaction`, values, error); + throw error; + }); }; func.estimateGas = (options, values = []) => { const _options = this._encodeOptions(func, this._addOptionsTo(options), values); - return this._api.eth.estimateGas(_options); + return this._api.eth + .estimateGas(_options) + .catch((error) => { + console.warn(`${func.name}.estimateGas`, values, error); + throw error; + }); }; } @@ -385,6 +399,10 @@ export default class Contract { this._subscribeToChanges(); return subscriptionId; }); + }) + .catch((error) => { + console.warn('subscribe', event, _options, error); + throw error; }); } diff --git a/js/src/redux/providers/personalActions.js b/js/src/redux/providers/personalActions.js index 5d91aeef8..d16e722bf 100644 --- a/js/src/redux/providers/personalActions.js +++ b/js/src/redux/providers/personalActions.js @@ -75,6 +75,9 @@ export function personalAccountsInfo (accountsInfo) { return wallet; }); }) + .catch(() => { + return []; + }) .then((_wallets) => { _wallets.forEach((wallet) => { const owners = wallet.owners.map((o) => o.address); @@ -96,6 +99,10 @@ export function personalAccountsInfo (accountsInfo) { dispatch(_personalAccountsInfo(data)); dispatch(attachWallets(wallets)); dispatch(fetchBalances()); + }) + .catch((error) => { + console.warn('personalAccountsInfo', error); + throw error; }); }; } diff --git a/js/src/views/Dapps/dappsStore.js b/js/src/views/Dapps/dappsStore.js index 8cca4d3f7..efbde9ef4 100644 --- a/js/src/views/Dapps/dappsStore.js +++ b/js/src/views/Dapps/dappsStore.js @@ -256,7 +256,7 @@ export default class DappsStore { store.set(LS_KEY_DISPLAY, this.displayApps); } - @action addApps = (_apps) => { + @action addApps = (_apps = []) => { transaction(() => { const apps = _apps.filter((app) => app);