Skip to content

src, os, dgram, tty: migrate to internal errors#16567

Closed
jasnell wants to merge 4 commits into
nodejs:masterfrom
jasnell:migrate-os-internal-errors
Closed

src, os, dgram, tty: migrate to internal errors#16567
jasnell wants to merge 4 commits into
nodejs:masterfrom
jasnell:migrate-os-internal-errors

Conversation

@jasnell

@jasnell jasnell commented Oct 28, 2017

Copy link
Copy Markdown
Member
  • Adds mechanism for transitioning internal UV and ErrnoException to internal/errors
  • Migrates os, tty, and dgram errors to internal/errors
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)

src, os, dgram, tty

@nodejs-github-bot nodejs-github-bot added the lib / src Issues and PRs related to general changes in the lib or src directory. label Oct 28, 2017
@jasnell jasnell added 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. dgram Issues and PRs related to the dgram subsystem / UDP. os Issues and PRs related to the os subsystem. tty Issues and PRs related to the tty subsystem. labels Oct 28, 2017
@jasnell

jasnell commented Oct 28, 2017

Copy link
Copy Markdown
Member Author

ping @nodejs/tsc

@jasnell

jasnell commented Oct 28, 2017

Copy link
Copy Markdown
Member Author

That wouldn't catch cases like new SystemError(null)

@targos

targos commented Oct 28, 2017

Copy link
Copy Markdown
Member

Can't that case be changed to pass undefined?

Comment thread lib/internal/errors.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

context is guaranteed to be truthy here

@maclover7

Copy link
Copy Markdown
Contributor

This is really great! Should any docs be added on the C++ side about the new way to throw errors... maybe in the style guide?

@jasnell

jasnell commented Oct 29, 2017

Copy link
Copy Markdown
Member Author

@targos

Can't that case be changed to pass undefined

potentially. Let's save that particular change for later tho. Once I get through converting all of the native level code to use this I will verify that we can safely make that assumption.

@maclover7

Should any docs be added on the C++ side about the new way to throw errors

Yes, I'm planning to write up a more detailed guide on this once I'm through the initial conversion.

Comment thread doc/api/errors.md Outdated

@joyeecheung joyeecheung Oct 30, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Come to think of it, I think a more popular pattern in the userland is using the err.data property (correct me if I am wrong), I remember seeing some logging services/tools collect that automatically in addition to err.code...I remember there is another PR for crypto that use info. Is there a reason that we pick info instead of data?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've seen both: https://www.npmjs.com/package/verror uses *.info

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

On a side note: would be easier to read if we have a syntax for documenting optional properties..

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I agree, definitely something worth working on

@joyeecheung joyeecheung left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Changes LGTM, left a few suggestions.

Comment thread lib/dgram.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this for avoiding changing the error type? Maybe a comment because this looks a bit odd at first?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, I really dislike how this was done, but I want to save it for a different PR to change it.

Comment thread lib/os.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe name this function and do a captureStackTrace()?

Comment thread src/node_os.cc Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For clarity, maybe use args[args.Length() - 1]? Also we should probably CHECK_EQ(args.Length(), n) or CHECK_GE(args.Length(), n) (not sure if these are used in userland)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This one is not legacy, right? Should we move the comment below this?

Preparing for the migration of existing UVException and ErrnoExceptions
from the native layer, add new `errors.SystemError` to internal/errors
and new `env->CollectExceptionInfo()` / `env->CollectUVExceptionInfo()`
methods.
@jasnell jasnell force-pushed the migrate-os-internal-errors branch from 4a8cbd3 to ee9e7a6 Compare November 2, 2017 05:17
@jasnell

jasnell commented Nov 2, 2017

Copy link
Copy Markdown
Member Author

@targos @joyeecheung ... updated, PTAL

@mhdawson mhdawson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM as long as CI is green.

@mhdawson

mhdawson commented Nov 2, 2017

Copy link
Copy Markdown
Member

@jasnell

jasnell commented Nov 2, 2017

Copy link
Copy Markdown
Member Author

CI is good. failures are unrelated and known flakies

@jasnell

jasnell commented Nov 2, 2017

Copy link
Copy Markdown
Member Author

(getting this landed)

jasnell added a commit that referenced this pull request Nov 2, 2017
Preparing for the migration of existing UVException and ErrnoExceptions
from the native layer, add new `errors.SystemError` to internal/errors
and new `env->CollectExceptionInfo()` / `env->CollectUVExceptionInfo()`
methods.

PR-URL: #16567
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
jasnell added a commit that referenced this pull request Nov 2, 2017
PR-URL: #16567
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
jasnell added a commit that referenced this pull request Nov 2, 2017
PR-URL: #16567
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
jasnell added a commit that referenced this pull request Nov 2, 2017
PR-URL: #16567
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
@jasnell

jasnell commented Nov 2, 2017

Copy link
Copy Markdown
Member Author

Landed in c3dc0e0, 056b858, 3d9d849, and 9ad994b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dgram Issues and PRs related to the dgram subsystem / UDP. errors Issues and PRs related to JavaScript errors originated in Node.js core. lib / src Issues and PRs related to general changes in the lib or src directory. os Issues and PRs related to the os subsystem. semver-major PRs that contain breaking changes and should be released in the next major version. tty Issues and PRs related to the tty subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants