1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-03 14:59:18 +02:00

Better loaderror handling

This commit is contained in:
Fred Chasen 2017-11-03 13:41:39 -07:00
parent 7c6fbfe978
commit b1093fa841
4 changed files with 38 additions and 17 deletions

View file

@ -236,9 +236,13 @@ class ContinuousViewManager extends DefaultViewManager {
// console.log("visible " + view.index); // console.log("visible " + view.index);
if (!view.displayed) { if (!view.displayed) {
promises.push(view.display(this.request).then(function (view) { let displayed = view.display(this.request)
.then(function (view) {
view.show(); view.show();
})); }, (err) => {
view.hide();
});
promises.push(displayed);
} else { } else {
view.show(); view.show();
} }
@ -256,7 +260,10 @@ class ContinuousViewManager extends DefaultViewManager {
} }
if(promises.length){ if(promises.length){
return Promise.all(promises); return Promise.all(promises)
.catch((err) => {
updating.reject(err);
})
} else { } else {
updating.resolve(); updating.resolve();
return updating.promise; return updating.promise;
@ -316,8 +323,9 @@ class ContinuousViewManager extends DefaultViewManager {
.then(() => { .then(() => {
// Check to see if anything new is on screen after rendering // Check to see if anything new is on screen after rendering
return this.update(delta); return this.update(delta);
}, (err) => {
return err;
}); });
} else { } else {
this.q.enqueue(function(){ this.q.enqueue(function(){
this.update(); this.update();

View file

@ -264,7 +264,9 @@ class DefaultViewManager {
this.moveTo(offset); this.moveTo(offset);
} }
}.bind(this)) }.bind(this), (err) => {
displaying.reject(err);
})
.then(function(){ .then(function(){
var next; var next;
if (this.layout.name === "pre-paginated" && if (this.layout.name === "pre-paginated" &&
@ -445,7 +447,9 @@ class DefaultViewManager {
return this.append(right); return this.append(right);
} }
} }
}.bind(this)) }.bind(this), (err) => {
displaying.reject(err);
})
.then(function(){ .then(function(){
this.views.show(); this.views.show();
}.bind(this)); }.bind(this));
@ -517,7 +521,9 @@ class DefaultViewManager {
return this.prepend(left); return this.prepend(left);
} }
} }
}.bind(this)) }.bind(this), (err) => {
displaying.reject(err);
})
.then(function(){ .then(function(){
if(this.isPaginated && this.settings.axis === "horizontal") { if(this.isPaginated && this.settings.axis === "horizontal") {
if (this.settings.direction === "rtl") { if (this.settings.direction === "rtl") {

View file

@ -166,12 +166,14 @@ class IframeView {
resolve(); resolve();
}); });
}.bind(this), function(e){
this.emit("loaderror", e);
return new Promise((resolve, reject) => {
reject(e);
});
}.bind(this)) }.bind(this))
.then(function() { .then(function() {
this.emit("rendered", this.section); this.emit("rendered", this.section);
}.bind(this))
.catch(function(e){
this.emit("loaderror", e);
}.bind(this)); }.bind(this));
} }
@ -445,7 +447,8 @@ class IframeView {
if (!this.displayed) { if (!this.displayed) {
this.render(request).then(function () { this.render(request)
.then(function () {
this.emit("displayed", this); this.emit("displayed", this);
this.onDisplayed(this); this.onDisplayed(this);
@ -453,7 +456,9 @@ class IframeView {
this.displayed = true; this.displayed = true;
displayed.resolve(this); displayed.resolve(this);
}.bind(this)); }.bind(this), function (err) {
displayed.reject(err, this);
});
} else { } else {
displayed.resolve(this); displayed.resolve(this);

View file

@ -271,6 +271,8 @@ class Rendition {
this.emit("displayed", section); this.emit("displayed", section);
this.reportLocation(); this.reportLocation();
}, (err) => {
this.emit("displayerror", err);
}); });
return displayed; return displayed;