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

Fix error properties #375

Merged
merged 1 commit into from Oct 14, 2019
Merged

Fix error properties #375

merged 1 commit into from Oct 14, 2019

Conversation

ehmicky
Copy link
Collaborator

@ehmicky ehmicky commented Oct 10, 2019

The exitCode and exitCodeName are currently wrong.

We use error.code as the base for exitCode and exitCodeName. We also use util.getSystemErrorName() on an exit code. Both are erroneous as they are mixing exit codes and error.code/error.errno, which are different things. error.code and error.errno are based on OS-specific system calls. Those are sometimes used as exit codes, but an exit code does not always translate to an error.errno.

Assigning a name or description to exit codes is tricky. That's because exit codes meaning is both application-specific and OS-specific. For example, the exit code 2 means "Command line usage error" if the command is bash. But it means "ENOENT - No such file or directory" if the error was due to a Linux system call error.

This PR fixes this by:

  • removing error.exitCodeName (breaking change).
  • not making exitCode use error.code anymore
  • keeping error.code when defined instead of deleting it
  • adding the error message Command failed with ${error.code} when error.code is defined
  • improving error-related tests
  • renaming the internal variable code to exitCode for clarity

@sindresorhus sindresorhus merged commit c1b511b into master Oct 14, 2019
@sindresorhus sindresorhus deleted the feat/error-properties branch October 14, 2019 14:01
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