From 531943a21b021000ccdbad2b2c262927b73e5f19 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Thu, 8 Nov 2018 12:24:36 +0100 Subject: [PATCH 1/4] Return only error msg from res --- app/src/main/index.js | 12 ++++++------ app/src/renderer/components/wallet/PageSend.vue | 8 ++++---- app/src/renderer/main.js | 6 +++--- app/src/renderer/vuex/modules/blockchain.js | 4 +--- app/src/renderer/vuex/modules/send.js | 2 +- archive/components/NiVotes.vue | 4 ++-- 6 files changed, 17 insertions(+), 19 deletions(-) diff --git a/app/src/main/index.js b/app/src/main/index.js index 1358ab337b..1ee3df5dbc 100644 --- a/app/src/main/index.js +++ b/app/src/main/index.js @@ -82,14 +82,14 @@ function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)) } -function handleCrash(error) { +function handleCrash(err) { afterBooted(() => { if (mainWindow) { mainWindow.webContents.send(`error`, { - message: error - ? error.message - ? error.message - : error + message: err + ? err.message + ? err.message + : err : `An unspecified error occurred` }) } @@ -315,7 +315,7 @@ function stopLCD() { lcdProcess.kill(`SIGKILL`) } catch (err) { handleCrash(err) - reject(`Stopping the LCD resulted in an error: ` + err.message) + reject(`Stopping the LCD resulted in an error: ${err.message}`) } }) } diff --git a/app/src/renderer/components/wallet/PageSend.vue b/app/src/renderer/components/wallet/PageSend.vue index df3fc5ccb6..fae0d240ca 100644 --- a/app/src/renderer/components/wallet/PageSend.vue +++ b/app/src/renderer/components/wallet/PageSend.vue @@ -168,8 +168,8 @@ export default { } catch (err) { this.sending = false this.$store.commit(`notifyError`, { - title: `Error Sending`, - body: `An error occurred while trying to send: "${err.message}"` + title: `Error Sending ${denom}`, + body: err.message }) } }, @@ -181,8 +181,8 @@ export default { b32.decode(param) this.bech32error = null return true - } catch (error) { - this.bech32error = error.message + } catch (err) { + this.bech32error = err.message return false } }, diff --git a/app/src/renderer/main.js b/app/src/renderer/main.js index ab2247311d..cd9ccfe784 100644 --- a/app/src/renderer/main.js +++ b/app/src/renderer/main.js @@ -85,14 +85,14 @@ async function main() { next() }) - ipcRenderer.on(`error`, (event, error) => { - switch (error.code) { + ipcRenderer.on(`error`, (event, err) => { + switch (err.code) { case `NO_NODES_AVAILABLE`: store.commit(`setModalNoNodes`, true) break default: store.commit(`setModalError`, true) - store.commit(`setModalErrorMessage`, error.message) + store.commit(`setModalErrorMessage`, err.message) } }) ipcRenderer.on(`approve-hash`, (event, hash) => { diff --git a/app/src/renderer/vuex/modules/blockchain.js b/app/src/renderer/vuex/modules/blockchain.js index 30b51033f8..ec1c9de013 100644 --- a/app/src/renderer/vuex/modules/blockchain.js +++ b/app/src/renderer/vuex/modules/blockchain.js @@ -72,9 +72,7 @@ export default ({ node }) => { function error(err) { dispatch(`nodeHasHalted`) - console.error( - `Error subscribing to new blocks: ${err.message} ${err.data || ``}` - ) + console.error(err.message) } node.rpc.status((err, status) => { diff --git a/app/src/renderer/vuex/modules/send.js b/app/src/renderer/vuex/modules/send.js index 5ee72080ca..f65a3ba418 100644 --- a/app/src/renderer/vuex/modules/send.js +++ b/app/src/renderer/vuex/modules/send.js @@ -93,6 +93,6 @@ function assertOk(res) { if (res.check_tx.code || res.deliver_tx.code) { let message = res.check_tx.log || res.deliver_tx.log - throw new Error(`Error sending transaction: ` + message) + throw new Error(`Error sending transaction: ${message}`) } } diff --git a/archive/components/NiVotes.vue b/archive/components/NiVotes.vue index 1e86e4174a..cbf3385a0a 100644 --- a/archive/components/NiVotes.vue +++ b/archive/components/NiVotes.vue @@ -39,10 +39,10 @@ export default { rootId: this.parent.rootId, // for comments userUid: this.user.uid }) - .then(null, error => { + .then(null, err => { this.$store.commit("notifyError", { title: "Updating vote failed", - body: error.message + body: err.message }) }) } From 1282ea5bb46f35d642043ac61b983af500bc8204 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Thu, 8 Nov 2018 12:26:31 +0100 Subject: [PATCH 2/4] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7573d23f3..50066db0c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. * [\#1409](https://github.com/cosmos/voyager/issues/1409) Fixed disabled unbond and redelegation button when delegation amount was less than 1 @fedekunze * [\#1517](https://github.com/cosmos/voyager/issues/1517) Fixed wrong account format used for querying selfBond @faboweb * [\#1503](https://github.com/cosmos/voyager/issues/1503) Added e2e test for balance updates after delegation @faboweb +* [\#1131](https://github.com/cosmos/voyager/issues/1131) Display only error message on notifications @fedekunze ## [0.10.7] - 2018-10-10 From 44626a4f4ebdd4b76699edc1852a9bde446c0064 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Thu, 8 Nov 2018 12:34:53 +0100 Subject: [PATCH 3/4] update snapshots --- app/src/renderer/components/wallet/PageSend.vue | 2 +- test/unit/specs/components/wallet/PageSend.spec.js | 5 +++-- .../components/wallet/__snapshots__/PageSend.spec.js.snap | 4 ++-- .../unit/specs/store/__snapshots__/transactions.spec.js.snap | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/renderer/components/wallet/PageSend.vue b/app/src/renderer/components/wallet/PageSend.vue index fae0d240ca..db606f26b7 100644 --- a/app/src/renderer/components/wallet/PageSend.vue +++ b/app/src/renderer/components/wallet/PageSend.vue @@ -168,7 +168,7 @@ export default { } catch (err) { this.sending = false this.$store.commit(`notifyError`, { - title: `Error Sending ${denom}`, + title: `Error Sending ${denom}s`, body: err.message }) } diff --git a/test/unit/specs/components/wallet/PageSend.spec.js b/test/unit/specs/components/wallet/PageSend.spec.js index f745e11ccd..15119e9881 100644 --- a/test/unit/specs/components/wallet/PageSend.spec.js +++ b/test/unit/specs/components/wallet/PageSend.spec.js @@ -208,9 +208,10 @@ describe(`PageSend`, () => { }) it(`should show notification for unsuccessful send`, async () => { + let denom = `notmycoin` wrapper.setData({ fields: { - denom: `notmycoin`, + denom, address, amount: 2, zoneId: `cosmos-hub-1` @@ -219,7 +220,7 @@ describe(`PageSend`, () => { node.sign = () => Promise.reject() await wrapper.vm.onApproved() expect(store.state.notifications.length).toBe(1) - expect(store.state.notifications[0].title).toBe(`Error Sending`) + expect(store.state.notifications[0].title).toBe(`Error Sending ${denom}s`) expect(store.state.notifications[0]).toMatchSnapshot() }) diff --git a/test/unit/specs/components/wallet/__snapshots__/PageSend.spec.js.snap b/test/unit/specs/components/wallet/__snapshots__/PageSend.spec.js.snap index de2ba04e4a..a8f04c6abb 100644 --- a/test/unit/specs/components/wallet/__snapshots__/PageSend.spec.js.snap +++ b/test/unit/specs/components/wallet/__snapshots__/PageSend.spec.js.snap @@ -2056,11 +2056,11 @@ exports[`PageSend should show bech32 error when alphanumeric is wrong 1`] = ` exports[`PageSend should show notification for unsuccessful send 1`] = ` Object { - "body": "An error occurred while trying to send: \\"Error sending transaction: Not enough coins in your account\\"", + "body": "Error sending transaction: Not enough coins in your account", "icon": "error", "layout": "alert", "time": 42000, - "title": "Error Sending", + "title": "Error Sending notmycoins", "type": "error", } `; diff --git a/test/unit/specs/store/__snapshots__/transactions.spec.js.snap b/test/unit/specs/store/__snapshots__/transactions.spec.js.snap index b0cb14e88f..bfb80eafe0 100644 --- a/test/unit/specs/store/__snapshots__/transactions.spec.js.snap +++ b/test/unit/specs/store/__snapshots__/transactions.spec.js.snap @@ -359,7 +359,7 @@ Array [ "value": Object { "inputs": Array [ Object { - "address": "tb1cy0q7p", + "address": "tb1tgf90nch", "coins": Array [ Object { "amount": "1234", From f95d4a3c5cc5a10ba16a882a606320e750ed0319 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Thu, 8 Nov 2018 12:43:42 +0100 Subject: [PATCH 4/4] delete 'Error sending transaction' msg on body --- app/src/renderer/components/wallet/PageSend.vue | 2 +- app/src/renderer/vuex/modules/send.js | 4 ++-- test/unit/specs/components/wallet/PageSend.spec.js | 5 ++--- .../components/wallet/__snapshots__/PageSend.spec.js.snap | 4 ++-- .../unit/specs/store/__snapshots__/transactions.spec.js.snap | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/src/renderer/components/wallet/PageSend.vue b/app/src/renderer/components/wallet/PageSend.vue index db606f26b7..172ead2e22 100644 --- a/app/src/renderer/components/wallet/PageSend.vue +++ b/app/src/renderer/components/wallet/PageSend.vue @@ -168,7 +168,7 @@ export default { } catch (err) { this.sending = false this.$store.commit(`notifyError`, { - title: `Error Sending ${denom}s`, + title: `Error Sending transaction`, body: err.message }) } diff --git a/app/src/renderer/vuex/modules/send.js b/app/src/renderer/vuex/modules/send.js index f65a3ba418..a1cb130deb 100644 --- a/app/src/renderer/vuex/modules/send.js +++ b/app/src/renderer/vuex/modules/send.js @@ -86,13 +86,13 @@ export default ({ node }) => { function assertOk(res) { if (Array.isArray(res)) { - if (res.length === 0) throw new Error(`Error sending transaction.`) + if (res.length === 0) throw new Error(`Error sending transaction`) return res.forEach(assertOk) } if (res.check_tx.code || res.deliver_tx.code) { let message = res.check_tx.log || res.deliver_tx.log - throw new Error(`Error sending transaction: ${message}`) + throw new Error(message) } } diff --git a/test/unit/specs/components/wallet/PageSend.spec.js b/test/unit/specs/components/wallet/PageSend.spec.js index 15119e9881..ad2c750e6b 100644 --- a/test/unit/specs/components/wallet/PageSend.spec.js +++ b/test/unit/specs/components/wallet/PageSend.spec.js @@ -208,10 +208,9 @@ describe(`PageSend`, () => { }) it(`should show notification for unsuccessful send`, async () => { - let denom = `notmycoin` wrapper.setData({ fields: { - denom, + denom: `notmycoin`, address, amount: 2, zoneId: `cosmos-hub-1` @@ -220,7 +219,7 @@ describe(`PageSend`, () => { node.sign = () => Promise.reject() await wrapper.vm.onApproved() expect(store.state.notifications.length).toBe(1) - expect(store.state.notifications[0].title).toBe(`Error Sending ${denom}s`) + expect(store.state.notifications[0].title).toBe(`Error Sending transaction`) expect(store.state.notifications[0]).toMatchSnapshot() }) diff --git a/test/unit/specs/components/wallet/__snapshots__/PageSend.spec.js.snap b/test/unit/specs/components/wallet/__snapshots__/PageSend.spec.js.snap index a8f04c6abb..bfcb818b26 100644 --- a/test/unit/specs/components/wallet/__snapshots__/PageSend.spec.js.snap +++ b/test/unit/specs/components/wallet/__snapshots__/PageSend.spec.js.snap @@ -2056,11 +2056,11 @@ exports[`PageSend should show bech32 error when alphanumeric is wrong 1`] = ` exports[`PageSend should show notification for unsuccessful send 1`] = ` Object { - "body": "Error sending transaction: Not enough coins in your account", + "body": "Not enough coins in your account", "icon": "error", "layout": "alert", "time": 42000, - "title": "Error Sending notmycoins", + "title": "Error Sending transaction", "type": "error", } `; diff --git a/test/unit/specs/store/__snapshots__/transactions.spec.js.snap b/test/unit/specs/store/__snapshots__/transactions.spec.js.snap index bfb80eafe0..b0cb14e88f 100644 --- a/test/unit/specs/store/__snapshots__/transactions.spec.js.snap +++ b/test/unit/specs/store/__snapshots__/transactions.spec.js.snap @@ -359,7 +359,7 @@ Array [ "value": Object { "inputs": Array [ Object { - "address": "tb1tgf90nch", + "address": "tb1cy0q7p", "coins": Array [ Object { "amount": "1234",