I found the following code in a project, that I do not understand.:
get(key, store = null) {
if (!key) {
return new Error('There is no key to get!');
}
let dbstore = this.localforage;
if (store !== null) {
dbstore = store;
}
return dbstore
.getItem(key)
.then(function(value) {
return value;
})
.catch(function(err) {
return new Error('The key (' + key + ") isn't accessible: " + err);
});
}
Why return new Error('There is no key to get!'); instead of throw new Error('There is no key to get!');?
Also why not throw an error in the catch block?