Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Commit

Permalink
fix: catch errors when writing log file (#192)
Browse files Browse the repository at this point in the history
* try write dumps after log

* fix

* fix checks
  • Loading branch information
TheBrunoRM authored Aug 11, 2023
1 parent d03b4c2 commit c1d8305
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/parseItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ const catchAndLogFunc = (func, params = []) => {
const cfg = PATH.resolve(__dirname, '../package.json');
const bugsRef = require(cfg).bugs.url;

if (!FS.existsSync(dir)) FS.mkdirSync(dir);
FS.writeFileSync(file, JSON.stringify(params, null, 2));
/* eslint-disable no-console */
console.error(e.stack);
console.error(`\n/${'*'.repeat(200)}`);
Expand All @@ -107,6 +105,14 @@ const catchAndLogFunc = (func, params = []) => {
console.error(info);
console.error(`${'*'.repeat(200)}\\`);
/* eslint-enable no-console */

try {
if (!FS.existsSync(dir)) FS.mkdirSync(dir);
FS.writeFileSync(file, JSON.stringify(params, null, 2));
} catch (e2) {
console.warn('Could not write dumps to file:', e2);
}

return null;
}
};
Expand Down

0 comments on commit c1d8305

Please sign in to comment.