1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 22:58:07 +02:00

Merge pull request #19148 from nicolo-ribaudo/error-preserve-trace

Do not stringify errors when logging them
This commit is contained in:
Jonas Jenwald 2024-12-06 17:11:33 +01:00 committed by GitHub
commit c198e0b446
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 21 additions and 20 deletions

View file

@ -204,7 +204,7 @@ const PDFViewerApplication = {
try {
await this.preferences.initializedPromise;
} catch (ex) {
console.error(`initialize: "${ex.message}".`);
console.error("initialize:", ex);
}
if (AppOptions.get("pdfBugEnabled")) {
await this._parseHashParams();
@ -308,7 +308,7 @@ const PDFViewerApplication = {
await __non_webpack_import__(PDFWorker.workerSrc);
}
} catch (ex) {
console.error(`_parseHashParams: "${ex.message}".`);
console.error("_parseHashParams:", ex);
}
}
if (params.has("textlayer")) {
@ -324,7 +324,7 @@ const PDFViewerApplication = {
await loadPDFBug();
this._PDFBug.loadCSS();
} catch (ex) {
console.error(`_parseHashParams: "${ex.message}".`);
console.error("_parseHashParams:", ex);
}
break;
}
@ -337,7 +337,7 @@ const PDFViewerApplication = {
await loadPDFBug();
this._PDFBug.init(mainContainer, enabled);
} catch (ex) {
console.error(`_parseHashParams: "${ex.message}".`);
console.error("_parseHashParams:", ex);
}
}
// It is not possible to change locale for the (various) extension builds.
@ -1128,7 +1128,7 @@ const PDFViewerApplication = {
this.downloadManager.download(data, this._downloadUrl, this._docFilename);
} catch (reason) {
// When the PDF document isn't ready, fallback to a "regular" download.
console.error(`Error when saving the document: ${reason.message}`);
console.error(`Error when saving the document:`, reason);
await this.download();
} finally {
await this.pdfScriptingManager.dispatchDidSave();

View file

@ -93,7 +93,7 @@ class DownloadManager {
window.open(viewerUrl);
return true;
} catch (ex) {
console.error(`openOrDownloadData: ${ex}`);
console.error("openOrDownloadData:", ex);
// Release the `blobUrl`, since opening it failed, and fallback to
// downloading the PDF file.
URL.revokeObjectURL(blobUrl);

View file

@ -121,7 +121,7 @@ class DownloadManager {
window.open(viewerUrl);
return true;
} catch (ex) {
console.error(`openOrDownloadData: ${ex}`);
console.error("openOrDownloadData:", ex);
// Release the `blobUrl`, since opening it failed, and fallback to
// downloading the PDF file.
URL.revokeObjectURL(blobUrl);

View file

@ -85,7 +85,7 @@ class L10n {
try {
await this.#l10n.translateElements([element]);
} catch (ex) {
console.error(`translateOnce: "${ex}".`);
console.error("translateOnce:", ex);
}
}

View file

@ -402,7 +402,7 @@ class PDFPageView {
"display"
);
} catch (ex) {
console.error(`#renderAnnotationLayer: "${ex}".`);
console.error("#renderAnnotationLayer:", ex);
error = ex;
} finally {
this.#dispatchLayerRendered("annotationlayerrendered", error);
@ -414,7 +414,7 @@ class PDFPageView {
try {
await this.annotationEditorLayer.render(this.viewport, "display");
} catch (ex) {
console.error(`#renderAnnotationEditorLayer: "${ex}".`);
console.error("#renderAnnotationEditorLayer:", ex);
error = ex;
} finally {
this.#dispatchLayerRendered("annotationeditorlayerrendered", error);
@ -425,7 +425,7 @@ class PDFPageView {
try {
await this.drawLayer.render("display");
} catch (ex) {
console.error(`#renderDrawLayer: "${ex}".`);
console.error("#renderDrawLayer:", ex);
}
}
@ -441,7 +441,7 @@ class PDFPageView {
this.#buildXfaTextContentItems(result.textDivs);
}
} catch (ex) {
console.error(`#renderXfaLayer: "${ex}".`);
console.error("#renderXfaLayer:", ex);
error = ex;
} finally {
if (this.xfaLayer?.div) {
@ -466,7 +466,7 @@ class PDFPageView {
if (ex instanceof AbortException) {
return;
}
console.error(`#renderTextLayer: "${ex}".`);
console.error("#renderTextLayer:", ex);
error = ex;
}
this.#dispatchLayerRendered("textlayerrendered", error);

View file

@ -201,7 +201,7 @@ class PDFRenderingQueue {
if (reason instanceof RenderingCancelledException) {
return;
}
console.error(`renderView: "${reason}"`);
console.error("renderView:", reason);
});
break;
}

View file

@ -105,7 +105,7 @@ class PDFScriptingManager {
try {
this.#scripting = this.#initScripting();
} catch (error) {
console.error(`setDocument: "${error.message}".`);
console.error("setDocument:", error);
await this.#destroyScripting();
return;
@ -192,7 +192,7 @@ class PDFScriptingManager {
eventBus.dispatch("sandboxcreated", { source: this });
} catch (error) {
console.error(`setDocument: "${error.message}".`);
console.error("setDocument:", error);
await this.#destroyScripting();
return;

View file

@ -254,7 +254,7 @@ function webViewerLoad() {
} catch (ex) {
// The viewer could be in e.g. a cross-origin <iframe> element,
// fallback to dispatching the event at the current `document`.
console.error(`webviewerloaded: ${ex}`);
console.error("webviewerloaded:", ex);
document.dispatchEvent(event);
}
}