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: migrate lib/console #11340

Closed
wants to merge 1 commit into from
Closed

errors: migrate lib/console #11340

wants to merge 1 commit into from

Conversation

@mskec
Copy link
Contributor

@mskec mskec commented Feb 13, 2017

Migrate console.js to use internal/errors.js.

Refs: #11273

cc @jasnell

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)
lib/console.js Outdated
const util = require('util');

function Console(stdout, stderr) {
if (!(this instanceof Console)) {
return new Console(stdout, stderr);
}
if (!stdout || typeof stdout.write !== 'function') {
throw new TypeError('Console expects a writable stream instance');
throw new errors.TypeError('ERR_CONSOLE_WRTBLSTRM', 'stdout');

This comment has been minimized.

@jasnell

jasnell Feb 13, 2017
Member

I'd say just go ahead and write out WRITABLE_STREAM instead of abbreviating

lib/internal/errors.js Outdated
@@ -86,3 +86,5 @@ module.exports = exports = {
// Note: Please try to keep these in alphabetical order
E('ERR_ASSERTION', (msg) => msg);
// Add new errors from here...

E('ERR_CONSOLE_WRTBLSTRM', (streamName) => `Console expects a writable stream instance for ${streamName}`);

This comment has been minimized.

@jasnell

jasnell Feb 13, 2017
Member

Please line wrap at 80 chars

test/parallel/test-console-instance.js Outdated
@@ -18,14 +18,14 @@ assert.strictEqual('function', typeof Console);
// when not given a writable stream instance
assert.throws(() => {
new Console();
}, /^TypeError: Console expects a writable stream instance$/);
}, /^TypeError\[ERR_CONSOLE_WRTBLSTRM\]: Console expects a writable stream instance for stdout$/);

This comment has been minimized.

@jasnell

jasnell Feb 13, 2017
Member

Please use the new common.expectsError() method here.

@mskec
Copy link
Contributor Author

@mskec mskec commented Feb 13, 2017

Thank you for feedback.
Should I add error to docs? documenting new errors

@jasnell
Copy link
Member

@jasnell jasnell commented Feb 14, 2017

Yes, please add it to the docs using the pattern seen in the other PRs #11273

@jasnell jasnell mentioned this pull request Feb 14, 2017
79 of 80 tasks complete
@joyeecheung
Copy link
Member

@joyeecheung joyeecheung commented Feb 14, 2017

This looks like a duplicate of #11308, I've added that one to the tracking issue because that one is earlier.

@mskec
Copy link
Contributor Author

@mskec mskec commented Feb 14, 2017

@joyeecheung yes unfortunately I didn't see it before I started.
I think this PR is done now, but you decide which one you want.

@jasnell jasnell added the blocked label Apr 5, 2017
@refack refack force-pushed the nodejs:master branch to fbe946b Apr 14, 2017
@fhinkel
Copy link
Member

@fhinkel fhinkel commented May 23, 2017

@mskec Thanks so much for putting this together. Sorry that it is dragging out for so long due to being a semver-major change. Could you rebase and also squash your commits (I think all the changes should be one commit, right?). Thanks!

@mskec mskec force-pushed the mskec:errors-console branch to 9ef8396 May 23, 2017
@mskec
Copy link
Contributor Author

@mskec mskec commented May 24, 2017

@fhinkel I rebased and squashed commits. Let me know if there is anything else

@@ -112,6 +112,8 @@ module.exports = exports = {
// Note: Please try to keep these in alphabetical order
E('ERR_ARG_NOT_ITERABLE', '%s must be iterable');
E('ERR_ASSERTION', (msg) => msg);
E('ERR_CONSOLE_WRITABLE_STREAM',
(name) => `Console expects a writable stream instance for ${name}`);

This comment has been minimized.

@TimothyGu

TimothyGu May 25, 2017
Member

Why not use the %s syntax already used by several other format strings?

This comment has been minimized.

@mskec

mskec May 25, 2017
Author Contributor

No special reason. I made this PR when there was no other error messages using %s syntax.
Will change if you think that way is better

@fhinkel
Copy link
Member

@fhinkel fhinkel commented May 27, 2017

Thanks. Landed in 0ecdf29.

@fhinkel fhinkel closed this May 27, 2017
fhinkel added a commit that referenced this pull request May 27, 2017
Migrate console.js to use internal/errors.js.

PR-URL: #11340
Ref: #11273
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
@Trott Trott removed the blocked label Jul 11, 2017
@refack refack added this to Done in Error Codes Aug 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Error Codes
  
Done
Linked issues

Successfully merging this pull request may close these issues.

None yet

7 participants
You can’t perform that action at this time.