Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add try/catch when writing yarn-error.log #2095

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,9 @@ function onUnexpectedError(err: Error) {
log.push(`Trace: ${indent(err.stack)}`);

const errorLoc = path.join(config.cwd, 'yarn-error.log');
fs.writeFileSync(errorLoc, log.join('\n\n') + '\n');
try {
fs.writeFileSync(errorLoc, log.join('\n\n') + '\n');
} catch (err) {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably at least console.error or something rather than silently ignoring it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe something like reporter.error('Could not write yarn-error.log: ' + err) (with proper localized string)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing is, #346 already handles it marvelously. It just needs to get there. I was thinking to rather piggyback on that one, rather than handling it explicitly. But I can of course change into doing so.


reporter.error(reporter.lang('unexpectedError', err.message));
reporter.info(reporter.lang('bugReport', errorLoc));
Expand Down