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

errors, readline: migrate to use internal/errors.js #11390

Closed

Conversation

slammayjammay
Copy link
Contributor

@slammayjammay slammayjammay commented Feb 15, 2017

Migrate lib/readline.js to use internal/errors.js.

Refs: #11273

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

errors, readline

@nodejs-github-bot nodejs-github-bot added errors Issues and PRs related to JavaScript errors originated in Node.js core. readline Issues and PRs related to the built-in readline module. labels Feb 15, 2017
@jasnell jasnell added the semver-major PRs that contain breaking changes and should be released in the next major version. label Feb 15, 2017
lib/readline.js Outdated
@@ -66,7 +67,7 @@ function Interface(input, output, completer, terminal) {
if (typeof historySize !== 'number' ||
isNaN(historySize) ||
historySize < 0) {
throw new TypeError('Argument "historySize" must be a positive number');
throw new errors.TypeError('ERR_NON_NEGATIVE_NUMBER');
Copy link
Member

Choose a reason for hiding this comment

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

I think this is actually a RangeError? This looks like a ERR_INVALID_OPT_VALUE to me (refs: https://github.com/nodejs/node/pull/11300/files) too, but we can also make the message format of ERR_NON_NEGATIVE_NUMBER a function taking description of the variable that's negative, so we can keep the "historySize" part.

On another note, if we want to keep it as a ERR_NON_NEGATIVE_NUMBER, that code is missing documentation.

lib/readline.js Outdated
@@ -56,7 +57,7 @@ function Interface(input, output, completer, terminal) {
}

if (completer && typeof completer !== 'function') {
throw new TypeError('Argument "completer" must be a function');
throw new errors.TypeError('ERR_INVALID_CALLBACK');
Copy link
Member

Choose a reason for hiding this comment

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

the original message contains useful information(Argument "completer"), this looks like a ERR_INVALID_OPT_VALUE to me (refs: https://github.com/nodejs/node/pull/11300/files), passing the completer as an actual argument is not documented(refs: readline.createInterface()) so it doesn't fit the description of a Node.js style "callback" I think.

@jasnell jasnell added the blocked PRs that are blocked by other issues or PRs. label Apr 5, 2017
@fhinkel
Copy link
Member

fhinkel commented May 23, 2017

@slammayjammay Thanks so much for putting this together. Sorry that it is dragging out for so long due to being a semver-major change. Do you want to address the comments and rebase? Thanks!

@slammayjammay
Copy link
Contributor Author

@fhinkel Whoops, forgot about this! Sure, I'll find some time this week to address the feedback.

@slammayjammay slammayjammay force-pushed the internal-errors-readline branch 2 times, most recently from 049eaf2 to c4b4497 Compare May 24, 2017 05:16
@joyeecheung
Copy link
Member

@@ -559,7 +559,6 @@ found [here][online].
encountered by [`http`][] or [`net`][] -- often a sign that a `socket.end()`
was not properly called.


Copy link
Member

Choose a reason for hiding this comment

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

Accidental whitespace change?

@joyeecheung joyeecheung removed the blocked PRs that are blocked by other issues or PRs. label May 27, 2017
@@ -114,6 +114,7 @@ E('ERR_ARG_NOT_ITERABLE', '%s must be iterable');
E('ERR_ASSERTION', (msg) => msg);
E('ERR_INVALID_ARG_TYPE', invalidArgType);
E('ERR_INVALID_CALLBACK', 'callback must be a function');
E('ERR_INVALID_CURSOR_POS', 'Can\'t set cursor row without setting its column');
Copy link
Member

Choose a reason for hiding this comment

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

Would be great to avoid using contractions in the error messages.

E('ERR_INVALID_CURSOR_POS',
   'Cannot set cursor row without setting its column');

@joyeecheung
Copy link
Member

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

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

LGTM

@mhdawson
Copy link
Member

mhdawson commented Jun 6, 2017

@slammayjammay looks good, but unfortunately needs a rebase.

@joyeecheung
Copy link
Member

jasnell pushed a commit that referenced this pull request Jun 13, 2017
PR-URL: #11390
Ref: #11273
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
@jasnell
Copy link
Member

jasnell commented Jun 13, 2017

Landed in 7f3f72c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
errors Issues and PRs related to JavaScript errors originated in Node.js core. readline Issues and PRs related to the built-in readline module. semver-major PRs that contain breaking changes and should be released in the next major version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants