1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 01:58:06 +02:00

Add error backs for promises.

This commit is contained in:
Brendan Dahl 2012-01-04 16:13:53 -08:00
parent dba1a7dc6f
commit dddcb9c91b
2 changed files with 48 additions and 12 deletions

View file

@ -398,17 +398,25 @@ var Page = (function PageClosure() {
}
// Once the IRQueue and fonts are loaded, perform the actual rendering.
this.displayReadyPromise.then(function pageDisplayReadyPromise() {
var gfx = new CanvasGraphics(ctx, this.objs, textLayer);
try {
this.display(gfx, callback);
} catch (e) {
if (self.callback)
self.callback(e);
this.displayReadyPromise.then(
function pageDisplayReadyPromise() {
var gfx = new CanvasGraphics(ctx, this.objs, textLayer);
try {
this.display(gfx, callback);
} catch (e) {
if (callback)
callback(e);
else
throw e;
}
}.bind(this),
function pageDisplayReadPromiseError(reason) {
if (callback)
callback(reason);
else
throw e;
throw reason;
}
}.bind(this));
);
}
};
@ -722,8 +730,8 @@ var PDFDoc = (function PDFDocClosure() {
messageHandler.on('page_error', function pdfDocError(data) {
var page = this.pageCache[data.pageNum];
if (page.callback)
page.callback(data.error);
if (page.displayReadyPromise) {
page.displayReadyPromise.reject(data.error);}
else
throw data.error;
}, this);