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

Show error message in stdout. #1502

Merged
merged 2 commits into from
Nov 2, 2016
Merged

Show error message in stdout. #1502

merged 2 commits into from
Nov 2, 2016

Conversation

jvhoven
Copy link
Contributor

@jvhoven jvhoven commented Oct 27, 2016

Implements #1456.

When an unexpected error occurres it now shows the error message in console. I also renamed the old unexpectedError string to bugReport and gave it an info flag.

Test plan

I tested this by setting the permissions of my package.json to read-only and then attempt to install a new package using yarn add left-pad.

Instead of outputting:

error An unexpected error occurred, please open a bug report with the information provided in "/home/jeffrey/Documents/Projects/yarn-testing/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

It now outputs:

error An unexpected error occurred: "Error: EACCES: permission denied, open '/home/jeffrey/Documents/Projects/yarn-testing/package.json'\n    at Error (native)".
info If you think this is a bug, please open a bug report with the information provided in "/home/jeffrey/Documents/Projects/yarn-testing/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

@@ -315,7 +315,8 @@ function onUnexpectedError(err: Error) {
const errorLoc = path.join(config.cwd, 'yarn-error.log');
fs.writeFileSync(errorLoc, log.join('\n\n') + '\n');

reporter.error(reporter.lang('unexpectedError', errorLoc));
reporter.error(reporter.lang('unexpectedError', err.stack));
Copy link
Contributor Author

@jvhoven jvhoven Oct 27, 2016

Choose a reason for hiding this comment

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

Should I concat err.stack? It only shows the first part of the stack e.g: Error: EACCES: permission denied, open '/home/jeffrey/Documents/Projects/yarn-testing/package.json'\n at Error (native) but I'm not sure how that works as it might result in the entire stack being printed.

Copy link
Member

Choose a reason for hiding this comment

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

Try err.message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🙈, that would indeed be alot better.

@sebmck sebmck merged commit 855b45a into yarnpkg:master Nov 2, 2016
Jessidhia pushed a commit to Jessidhia/yarn that referenced this pull request Nov 4, 2016
* master: (66 commits)
  Add --no-bin-links flag - fixes yarnpkg#929 (yarnpkg#1651)
  Add option to change the prefix of the global bin folder - fixes yarnpkg#630 (yarnpkg#1654)
  patterns -> filteredPatterns
  Add helpful nudge to yarnpkg/rfcs on issue template (yarnpkg#1650)
  Change reporter.log to console.log in generate-lock-entry command - fixes yarnpkg#644 (yarnpkg#1652)
  Fixed add command flag (yarnpkg#1653)
  Nested executables fix (yarnpkg#1210)
  Added short-flags for yarn add (yarnpkg#1618)
  Add name lookups to ls command - fixes yarnpkg#1599 (yarnpkg#1643)
  Disable flaky secureUrl test (yarnpkg#1644)
  Add unit tests for `yarn why`. (yarnpkg#1544)
  Refine flow type for config.generateHardModulePath (yarnpkg#1642)
  Use ~/Library/Caches as default cache location on OSX - fixes yarnpkg#1637 (yarnpkg#1638)
  Update aliases.js (yarnpkg#1635)
  Update aliases.js (yarnpkg#1634)
  Add webhook to archive AppVeyor build artifacts (yarnpkg#1631)
  Attempt to fix failing Circle CI builds (yarnpkg#1629)
  Adding 'yarn global upgrade'(Issue yarnpkg#776) (yarnpkg#1616)
  Show error message in stdout. (yarnpkg#1502)
  Nicer permission errors when trying to write global binaries - fixes yarnpkg#1578 (yarnpkg#1592)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants