Remove the unneeded error-handling at the end of PDFViewerApplication.run

This is quite old code, however the error-handling no longer seems necessary for a couple of reasons:
 - The `PDFViewerApplication.open` method is asynchronous, which means that it cannot throw a "raw" `Error` and the try-catch is not needed in that case.
 - None of the other affected methods should throw, and if they do that'd rather indicate an *implementation* error in the code.
 - Finally, and most importantly, with the `PDFViewerApplication.run` method now being asynchronous an (unlikely) `Error` thrown within it will lead to a rejected `Promise` and not affect execution of other code.
This commit is contained in:
Jonas Jenwald 2023-07-26 10:39:51 +02:00
parent ecf95e552f
commit 2fbfd9517f

View File

@ -694,7 +694,7 @@ const PDFViewerApplication = {
async run(config) { async run(config) {
await this.initialize(config); await this.initialize(config);
const { appConfig, eventBus, l10n } = this; const { appConfig, eventBus } = this;
let file; let file;
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
const queryString = document.location.search.substring(1); const queryString = document.location.search.substring(1);
@ -745,7 +745,7 @@ const PDFViewerApplication = {
if (!this.supportsDocumentFonts) { if (!this.supportsDocumentFonts) {
AppOptions.set("disableFontFace", true); AppOptions.set("disableFontFace", true);
l10n.get("web_fonts_disabled").then(msg => { this.l10n.get("web_fonts_disabled").then(msg => {
console.warn(msg); console.warn(msg);
}); });
} }
@ -775,22 +775,16 @@ const PDFViewerApplication = {
true true
); );
try { if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { if (file) {
if (file) { this.open({ url: file });
this.open({ url: file });
} else {
this._hideViewBookmark();
}
} else if (PDFJSDev.test("MOZCENTRAL || CHROME")) {
this.initPassiveLoading(file);
} else { } else {
throw new Error("Not implemented: run"); this._hideViewBookmark();
} }
} catch (reason) { } else if (PDFJSDev.test("MOZCENTRAL || CHROME")) {
l10n.get("loading_error").then(msg => { this.initPassiveLoading(file);
this._documentError(msg, reason); } else {
}); throw new Error("Not implemented: run");
} }
}, },