1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Do not stringify errors when logging them

Converting errors to string drops their stack trace, making it more
difficult to debug their actual reason. We can instead pass the error
objects as-is to console.warn/error, so that Firefox/Chrome devtools
will show both the stack trace of the console.warn/error call, and the
original stack trace of the error.

This commit also enables the `unicorn/no-console-spaces` ESLint rule,
which avoids accidental extra spaces when passing multiple parameters to
`console.*` methods.
This commit is contained in:
Nicolò Ribaudo 2024-12-02 13:28:20 +01:00
parent d448953166
commit 202b26487f
No known key found for this signature in database
GPG key ID: AAFDA9101C58F338
12 changed files with 21 additions and 20 deletions

View file

@ -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);
}

View file

@ -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();

View file

@ -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);