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

error,test: migrating error to internal/errors #11505

Closed
wants to merge 1 commit into from

Conversation

larissayvette
Copy link
Contributor

Checklist
Affected core subsystem(s)

error,lib

Assign error code to TypeError in assert.js

@nodejs-github-bot nodejs-github-bot added assert Issues and PRs related to the assert subsystem. errors Issues and PRs related to JavaScript errors originated in Node.js core. labels Feb 22, 2017
@mscdex
Copy link
Contributor

mscdex commented Feb 22, 2017

Minor nit: there's a typo in the commit message: s/intenal/internal/

@Trott
Copy link
Member

Trott commented Feb 23, 2017

@@ -85,4 +85,5 @@ module.exports = exports = {
//
// Note: Please try to keep these in alphabetical order
E('ERR_ASSERTION', (msg) => msg);
E('ERR_ARG_FUNCTION', '"block" argument must be a function');
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 ERR_INVALID_ARG_TYPE would be more suitable for this, refs: https://github.com/nodejs/node/pull/11294/files, I believe the idea at the moment is that concurrent PRs can duplicate some of the error codes introduced in others in order to get a little bit more consistency.

Also whichever the error code would be, can you add the corresponding documentation for it? See Documenting new errors.

'TypeError: "block" argument must be a function');
assert.strictEqual(
e.toString(),
'TypeError[ERR_ARG_FUNCTION]: "block" argument must be a function');
Copy link
Member

Choose a reason for hiding this comment

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

Can you use common.expectsError for this? Also watch out for #11512

Copy link
Member

@Trott Trott Mar 3, 2017

Choose a reason for hiding this comment

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

#11512 has landed, so lines 584-595 can now be something like this:

const validationFunction = common.expectsError({
  code: 'ERR_ARG_FUNCTION',
  type: TypeError,
  message: '"block" argument must be a function'
});
assert.throws(() => { method(block); }, validationFunction);

@larissayvette larissayvette changed the title error,test: migrating error to intenal/errors error,test: migrating error to internal/errors Feb 24, 2017
@jasnell jasnell added the blocked PRs that are blocked by other issues or PRs. label Apr 5, 2017
@Trott
Copy link
Member

Trott commented May 6, 2017

Rebased, resolved conflicts, nits addressed, removing blocked label (/cc @jasnell), will run CI.

Are these things semver-major?

PTAL!

CI: https://ci.nodejs.org/job/node-test-pull-request/7909/

@Trott Trott removed the blocked PRs that are blocked by other issues or PRs. label May 6, 2017
@jasnell
Copy link
Member

jasnell commented May 6, 2017

Yes, they are semver-major for the initially switch over to internal/errors due to the likelihood of changing error messages and the fact that none of this has been ported back to any release branch.

@Trott Trott added the semver-major PRs that contain breaking changes and should be released in the next major version. label May 6, 2017

assert.ok(threw);
testBlockTypeError(assert.throws, 'string');
Copy link
Member

Choose a reason for hiding this comment

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

Just a suggestion, but I think it would be nice if these could be turned into
testBlockTypeError(() => assert.throws('string')); etc.

Copy link
Member

Choose a reason for hiding this comment

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

@addaleax Tempted to leave this PR as-is just so I can put your suggestion on a list for Code + Learn... Is that unhealthy? :-P

Copy link
Member

Choose a reason for hiding this comment

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

That’s perfectly okay :)

Copy link
Member

Choose a reason for hiding this comment

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

@addaleax Having a hard time writing this up for Code + Learn in a way that makes it clear why we want to do this. (Probably because I see it as a style preference.) Would you want to try? If not, no biggie, I'll just leave it off the list. We have enough tasks for the next Code + Learn.

Trott pushed a commit to Trott/io.js that referenced this pull request May 6, 2017
PR-URL: nodejs#11505
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@Trott
Copy link
Member

Trott commented May 6, 2017

Landed in 1c834e7

@Trott Trott closed this May 6, 2017
anchnk pushed a commit to anchnk/node that referenced this pull request May 19, 2017
PR-URL: nodejs#11505
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@jasnell jasnell mentioned this pull request May 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assert Issues and PRs related to the assert subsystem. errors Issues and PRs related to JavaScript errors originated in Node.js core. 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.

7 participants