Skip to content

Commit

Permalink
Merge pull request #19148 from nicolo-ribaudo/error-preserve-trace
Browse files Browse the repository at this point in the history
Do not stringify errors when logging them
  • Loading branch information
Snuffleupagus authored Dec 6, 2024
2 parents 60eba28 + 202b264 commit c198e0b
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 20 deletions.
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export default [
"perfectionist/sort-named-exports": "error",
"unicorn/no-abusive-eslint-disable": "error",
"unicorn/no-array-push-push": "error",
"unicorn/no-console-spaces": "error",
"unicorn/no-instanceof-array": "error",
"unicorn/no-invalid-remove-event-listener": "error",
"unicorn/no-new-buffer": "error",
Expand Down
2 changes: 1 addition & 1 deletion test/downloadutils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ async function downloadManifestFiles(manifest) {
try {
await downloadFile(file, url);
} catch (ex) {
console.error(`Error during downloading of ${url}: ${ex}`);
console.error(`Error during downloading of ${url}:`, ex);
fs.writeFileSync(file, ""); // making it empty file
fs.writeFileSync(`${file}.error`, ex);
}
Expand Down
2 changes: 1 addition & 1 deletion test/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,7 @@ class Driver {
resolve();
})
.catch(reason => {
console.warn(`Driver._send failed (${url}): ${reason}`);
console.warn(`Driver._send failed (${url}):`, reason);

this.inFlightRequests--;
resolve();
Expand Down
2 changes: 1 addition & 1 deletion test/unit/testreporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const TestReporter = function (browser) {
resolve();
})
.catch(reason => {
console.warn(`TestReporter - send failed (${action}): ${reason}`);
console.warn(`TestReporter - send failed (${action}):`, reason);
resolve();

send(action, json);
Expand Down
10 changes: 5 additions & 5 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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")) {
Expand All @@ -324,7 +324,7 @@ const PDFViewerApplication = {
await loadPDFBug();
this._PDFBug.loadCSS();
} catch (ex) {
console.error(`_parseHashParams: "${ex.message}".`);
console.error("_parseHashParams:", ex);
}
break;
}
Expand All @@ -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.
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion web/download_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion web/firefoxcom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion web/l10n.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class L10n {
try {
await this.#l10n.translateElements([element]);
} catch (ex) {
console.error(`translateOnce: "${ex}".`);
console.error("translateOnce:", ex);
}
}

Expand Down
10 changes: 5 additions & 5 deletions web/pdf_page_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ class PDFPageView {
"display"
);
} catch (ex) {
console.error(`#renderAnnotationLayer: "${ex}".`);
console.error("#renderAnnotationLayer:", ex);
error = ex;
} finally {
this.#dispatchLayerRendered("annotationlayerrendered", error);
Expand All @@ -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);
Expand All @@ -425,7 +425,7 @@ class PDFPageView {
try {
await this.drawLayer.render("display");
} catch (ex) {
console.error(`#renderDrawLayer: "${ex}".`);
console.error("#renderDrawLayer:", ex);
}
}

Expand All @@ -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) {
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion web/pdf_rendering_queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class PDFRenderingQueue {
if (reason instanceof RenderingCancelledException) {
return;
}
console.error(`renderView: "${reason}"`);
console.error("renderView:", reason);
});
break;
}
Expand Down
4 changes: 2 additions & 2 deletions web/pdf_scripting_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion web/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit c198e0b

Please sign in to comment.