More robust getPage() error handling.

This commit is contained in:
Yury Delendik 2017-08-03 17:24:19 -05:00
parent 0c95bc7d83
commit d0e93721ae
4 changed files with 33 additions and 3 deletions

View file

@ -56,6 +56,7 @@ class PDFPageView {
this.id = options.id;
this.renderingId = 'page' + this.id;
this.pdfPage = null;
this.pageLabel = null;
this.rotation = 0;
this.scale = options.scale || DEFAULT_SCALE;
@ -110,6 +111,7 @@ class PDFPageView {
this.reset();
if (this.pdfPage) {
this.pdfPage.cleanup();
this.pdfPage = null;
}
}
@ -341,6 +343,11 @@ class PDFPageView {
this.reset(); // Ensure that we reset all state to prevent issues.
}
if (!this.pdfPage) {
this.renderingState = RenderingStates.FINISHED;
return Promise.reject(new Error('Page is not loaded'));
}
this.renderingState = RenderingStates.RUNNING;
let pdfPage = this.pdfPage;