throw exeption if provider has not been set

This commit is contained in:
Iuri Matias 2018-01-10 11:31:26 -05:00
parent 82681fec8f
commit 471fb1a061
1 changed files with 24 additions and 6 deletions

View File

@ -188,18 +188,30 @@ EmbarkJS.Storage.Providers = {
};
EmbarkJS.Storage.saveText = function(text) {
if (!this.currentStorage) {
throw new Error('Storage provider not set; e.g EmbarkJS.Storage.setProvider("ipfs")');
}
return this.currentStorage.saveText(text);
};
EmbarkJS.Storage.get = function(hash) {
if (!this.currentStorage) {
throw new Error('Storage provider not set; e.g EmbarkJS.Storage.setProvider("ipfs")');
}
return this.currentStorage.get(hash);
};
EmbarkJS.Storage.uploadFile = function(inputSelector) {
if (!this.currentStorage) {
throw new Error('Storage provider not set; e.g EmbarkJS.Storage.setProvider("ipfs")');
}
return this.currentStorage.uploadFile(inputSelector);
};
EmbarkJS.Storage.getUrl = function(hash) {
if (!this.currentStorage) {
throw new Error('Storage provider not set; e.g EmbarkJS.Storage.setProvider("ipfs")');
}
return this.currentStorage.getUrl(hash);
};
@ -240,10 +252,16 @@ EmbarkJS.Messages.setProvider = function(provider, options) {
};
EmbarkJS.Messages.sendMessage = function(options) {
if (!this.currentMessages) {
throw new Error('Messages provider not set; e.g EmbarkJS.Messages.setProvider("whisper")');
}
return this.currentMessages.sendMessage(options);
};
EmbarkJS.Messages.listenTo = function(options) {
if (!this.currentMessages) {
throw new Error('Messages provider not set; e.g EmbarkJS.Messages.setProvider("whisper")');
}
return this.currentMessages.listenTo(options);
};