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

Remove dead code related to exit code names #223

Merged
merged 1 commit into from
May 7, 2019

Conversation

ehmicky
Copy link
Collaborator

@ehmicky ehmicky commented May 7, 2019

We have added some logic to improve error messages, based on the child process termination.

Some of this logic is unreachable, so this is dead code and can be removed.

  1. exitCodeName cannot be undefined when exitCode is defined. This is because (when missing) exitCodeName is retrieved using util.getSystemErrorName(exitCode), and that function always returns a value. When the exit code wrong is wrong (e.g. 255), it will return Unknown system error -255.

  2. exitCode cannot be undefined when exitCodeName is defined. This is because (when missing) exitCode is retrieve using os.constants.errno[error.code]. error.code is from child_process.on('error'). error.code is guaranteed to be a valid exit code, because it's set within Node.js not by users. I checked the Node.js source and it looks pretty solid. Exception: if user manually triggers child_process.emit('error') with an invalid error.code, but this seems like an edge case.

  3. Both signal, exitCode and exitCodeName are undefined. This just cannot happen if you check our current logic.

This also improves test coverage.

@ehmicky ehmicky requested a review from sindresorhus May 7, 2019 14:48
@sindresorhus sindresorhus merged commit 3e7ea99 into master May 7, 2019
@sindresorhus sindresorhus deleted the feature/exit-codes-names branch May 7, 2019 18:23
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.

2 participants