aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-11-30 07:54:10 +0800
committerDan Finlay <dan@danfinlay.com>2016-11-30 07:54:10 +0800
commit95bcc21a066d0849b0b5399a8d7825b01d6390aa (patch)
tree049f27faa136cbba35794aba844343c478d5a9a3 /app
parentdf0b89074b6939081828ebc214bc26ffa5a89659 (diff)
downloadtangerine-wallet-browser-95bcc21a066d0849b0b5399a8d7825b01d6390aa.tar
tangerine-wallet-browser-95bcc21a066d0849b0b5399a8d7825b01d6390aa.tar.gz
tangerine-wallet-browser-95bcc21a066d0849b0b5399a8d7825b01d6390aa.tar.bz2
tangerine-wallet-browser-95bcc21a066d0849b0b5399a8d7825b01d6390aa.tar.lz
tangerine-wallet-browser-95bcc21a066d0849b0b5399a8d7825b01d6390aa.tar.xz
tangerine-wallet-browser-95bcc21a066d0849b0b5399a8d7825b01d6390aa.tar.zst
tangerine-wallet-browser-95bcc21a066d0849b0b5399a8d7825b01d6390aa.zip
Add useful nodeify error message
If a nodified method does not return a Promise, it will throw an error, like this: ``` Error in event handler for (unknown): Error: The function setSelectedAccount did not return a Promise, but was nodeified. ```
Diffstat (limited to 'app')
-rw-r--r--app/scripts/lib/nodeify.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/app/scripts/lib/nodeify.js b/app/scripts/lib/nodeify.js
index 56b793852..51d89a8fb 100644
--- a/app/scripts/lib/nodeify.js
+++ b/app/scripts/lib/nodeify.js
@@ -6,12 +6,19 @@ module.exports = function (promiseFn) {
}
var cb = arguments[arguments.length - 1]
- return promiseFn.apply(this, args)
- .then(function (result) {
+ const nodeified = promiseFn.apply(this, args)
+
+ if (!nodeified) {
+ const methodName = String(promiseFn).split('(')[0]
+ throw new Error(`The ${methodName} did not return a Promise, but was nodeified.`)
+ }
+ nodeified.then(function (result) {
cb(null, result)
})
.catch(function (reason) {
cb(reason)
})
+
+ return nodeified
}
}