Fixing logic to return reject in promise

This commit is contained in:
Andy Nogueira 2017-03-14 12:37:58 -04:00
parent fdf0129e5d
commit a0af3ff5d9
2 changed files with 18 additions and 16 deletions

View File

@ -231,14 +231,15 @@ EmbarkJS.Storage.IPFS = {
EmbarkJS.Storage.connect = function(provider){ EmbarkJS.Storage.connect = function(provider){
var self = this; var self = this;
if (provider.toLowerCase() === EmbarkJS.Storage.Providers.IPFS) {
var promise = new Promise(function(resolve, reject) { var promise = new Promise(function(resolve, reject) {
if (provider.toLowerCase() === EmbarkJS.Storage.Providers.IPFS) {
resolve(self.currentStorage.ipfsConnection); resolve(self.currentStorage.ipfsConnection);
});
} }
else { else {
reject('Storage provider not supported'); var error = new Error(provider + ' storage provider not supported');
} reject(error);
};
});
return promise; return promise;
}; };

View File

@ -158,14 +158,15 @@ EmbarkJS.Storage.IPFS = {
EmbarkJS.Storage.connect = function(provider){ EmbarkJS.Storage.connect = function(provider){
var self = this; var self = this;
if (provider.toLowerCase() === EmbarkJS.Storage.Providers.IPFS) {
var promise = new Promise(function(resolve, reject) { var promise = new Promise(function(resolve, reject) {
if (provider.toLowerCase() === EmbarkJS.Storage.Providers.IPFS) {
resolve(self.currentStorage.ipfsConnection); resolve(self.currentStorage.ipfsConnection);
});
} }
else { else {
reject('Storage provider not supported'); var error = new Error(provider + ' storage provider not supported');
} reject(error);
};
});
return promise; return promise;
}; };