From a0af3ff5d9cf6dfb2418e90fbc51144af321619d Mon Sep 17 00:00:00 2001 From: Andy Nogueira Date: Tue, 14 Mar 2017 12:37:58 -0400 Subject: [PATCH] Fixing logic to return reject in promise --- js/build/embark.bundle.js | 17 +++++++++-------- js/embark.js | 17 +++++++++-------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/js/build/embark.bundle.js b/js/build/embark.bundle.js index f3a09a2c..62b08ae5 100644 --- a/js/build/embark.bundle.js +++ b/js/build/embark.bundle.js @@ -231,14 +231,15 @@ EmbarkJS.Storage.IPFS = { EmbarkJS.Storage.connect = function(provider){ var self = this; - if (provider.toLowerCase() === EmbarkJS.Storage.Providers.IPFS) { - var promise = new Promise(function(resolve, reject) { - resolve(self.currentStorage.ipfsConnection); - }); - } - else { - reject('Storage provider not supported'); - } + var promise = new Promise(function(resolve, reject) { + if (provider.toLowerCase() === EmbarkJS.Storage.Providers.IPFS) { + resolve(self.currentStorage.ipfsConnection); + } + else { + var error = new Error(provider + ' storage provider not supported'); + reject(error); + }; + }); return promise; }; diff --git a/js/embark.js b/js/embark.js index b874b04a..c01e58cc 100644 --- a/js/embark.js +++ b/js/embark.js @@ -158,14 +158,15 @@ EmbarkJS.Storage.IPFS = { EmbarkJS.Storage.connect = function(provider){ var self = this; - if (provider.toLowerCase() === EmbarkJS.Storage.Providers.IPFS) { - var promise = new Promise(function(resolve, reject) { - resolve(self.currentStorage.ipfsConnection); - }); - } - else { - reject('Storage provider not supported'); - } + var promise = new Promise(function(resolve, reject) { + if (provider.toLowerCase() === EmbarkJS.Storage.Providers.IPFS) { + resolve(self.currentStorage.ipfsConnection); + } + else { + var error = new Error(provider + ' storage provider not supported'); + reject(error); + }; + }); return promise; };