From df5cc16646f93f92949b015473bb1deb407d447d Mon Sep 17 00:00:00 2001 From: andrepimenta Date: Mon, 26 Apr 2021 16:00:46 +0100 Subject: [PATCH 1/2] Add error info for getKeyringForAccount --- index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 8a0d67bc..6b456ca0 100644 --- a/index.js +++ b/index.js @@ -676,7 +676,19 @@ class KeyringController extends EventEmitter { if (winners && winners.length > 0) { return winners[0][0] } - throw new Error('No keyring found for the requested account.') + + // Adding more info to the error + let errorInfo = 'Error info: ' + if (!address) { + errorInfo += 'Empty address; ' + } + if (!candidates || !candidates.length) { + errorInfo += 'Empty candidates; ' + } + if (!winners || !winners.length) { + errorInfo += 'Empty winners;' + } + throw new Error(`No keyring found for the requested account. ${errorInfo}`) }) } From 72cde4754a64ad150bdb5a507a5f17796fb681ac Mon Sep 17 00:00:00 2001 From: andrepimenta Date: Tue, 4 May 2021 15:34:00 +0100 Subject: [PATCH 2/2] Improve the error messages --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 6b456ca0..250ab984 100644 --- a/index.js +++ b/index.js @@ -680,13 +680,13 @@ class KeyringController extends EventEmitter { // Adding more info to the error let errorInfo = 'Error info: ' if (!address) { - errorInfo += 'Empty address; ' + errorInfo += 'The address passed in is invalid/empty; ' } if (!candidates || !candidates.length) { - errorInfo += 'Empty candidates; ' + errorInfo += 'There are no keyrings; ' } if (!winners || !winners.length) { - errorInfo += 'Empty winners;' + errorInfo += 'There are keyrings, but none match the address;' } throw new Error(`No keyring found for the requested account. ${errorInfo}`)