Skip to content

Commit

Permalink
fix error propagation from null data
Browse files Browse the repository at this point in the history
  • Loading branch information
lukesmurray committed May 28, 2020
1 parent c16d09b commit 20ce135
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/mavo.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,14 +477,20 @@ var _ = self.Mavo = $.Class({

return backend.ready.then(() => backend.load())
.catch(err => {
// Try again with init
// if init exists, return null so load from init is attempted
if (this.init && this.init != backend) {
backend = this.init;
return this.init.ready.then(() => this.init.load());
return null
}

// No init, propagate error
return Promise.reject(err);
}).then(data => {
// if data is null and init exists try to load with init
if (data === null && this.init && this.init != backend) {
backend = this.init;
return this.init.ready.then(() => this.init.load());
}
return data;
})
.catch(err => {
if (err) {
Expand Down

0 comments on commit 20ce135

Please sign in to comment.