Skip to content

errors: move error codes into separate module - #14250

Closed
starkwang wants to merge 1 commit into
nodejs:masterfrom
starkwang:separate-error-codes
Closed

starkwang wants to merge 1 commit into
nodejs:masterfrom
starkwang:separate-error-codes

Conversation

@starkwang

@starkwang starkwang commented Jul 15, 2017 •

Copy link
Copy Markdown
Contributor

Move error codes into a new separate module internal/error_codes. And the guides/using-internal-errors.md are also changed.

This PR only separate the error codes in internal/errors.js. I think the rest of error codes in ./lib should wait for some future PRs.

Ref: #14216, #11273

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

errors

@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to Node.js builds or CI infrastructure. errors Issues and PRs related to JavaScript errors originating in Node.js core. labels Jul 15, 2017
@Trott

Trott commented Jul 15, 2017

Copy link
Copy Markdown
Member

Would it be better to create an internal/errors directory, move internal/errors.js to internal/errors/index.js and put the codes in internal/errors/codes.js?

Comment thread doc/guides/using-internal-errors.md Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Linting nit: missing semicolon.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

@starkwang
starkwang force-pushed the separate-error-codes branch 2 times, most recently from 30a8307 to 7610dbe Compare July 15, 2017 14:21
@vsemozhetbyt vsemozhetbyt added the doc Issues and PRs related to Node.js documentation. label Jul 15, 2017
@starkwang

starkwang commented Jul 15, 2017 •

Copy link
Copy Markdown
Contributor Author

@Trott I tried to create an internal/errors directory (with index.js and codes.js in it), but found the module system failed to load internal/errors/index.js whenrequire('internal/errors')

Error [ERR_UNKNOWN_BUILTIN_MODULE]: No such built-in module: internal/errors

@Trott

Trott commented Jul 15, 2017

Copy link
Copy Markdown
Member

@starkwang Ah! It looks like we may have run into a similar issue with internal/process and we just left lib/internal/process.js and put other files in lib/internal/process/. So maybe you can do that. (In other words, leave internal/errors.js where it is now but create internal/errors directory and put codes.js in there.)

@starkwang
starkwang force-pushed the separate-error-codes branch from 7610dbe to ef6c0c2 Compare July 15, 2017 15:01
@starkwang

Copy link
Copy Markdown
Contributor Author

Pushed commit to address comments.

@Trott Trott 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.

Needs one small doc change but otherwise looks good to me if the CI is green.

Comment thread doc/guides/using-internal-errors.md 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.

The path here needs to be updated to reflect the new location of the file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Doc fixed.

@Trott

Trott commented Jul 15, 2017

Copy link
Copy Markdown
Member

/cc @jasnell

@starkwang
starkwang force-pushed the separate-error-codes branch from ef6c0c2 to dc185e6 Compare July 15, 2017 15:30

@Trott Trott 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 if CI is green.

@starkwang
starkwang force-pushed the separate-error-codes branch 3 times, most recently from 9210f2d to 93ec771 Compare July 18, 2017 07:56
@starkwang
starkwang force-pushed the separate-error-codes branch from 93ec771 to 7576dd4 Compare July 18, 2017 08:04
@joyeecheung

Copy link
Copy Markdown
Member

Ping @starkwang, this needs a rebase.

@jasnell jasnell 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.

FWIW, I am -1 on this approach as it currently stands. There is no reason to move the codes to a separate file and doing so now would unnecessarily disrupt the current ongoing migration process. If we want to expose the codes as constants, then those can be dropped off the existing internal/errors module.exports target.

@refack

refack commented Jul 24, 2017

Copy link
Copy Markdown
Contributor

FWIW, I am -1 on this approach as it currently stands. There is no reason to move the codes to a separate file and doing so now would unnecessarily disrupt the current ongoing migration process. If we want to expose the codes as constants, then those can be dropped off the existing internal/errors module.exports target.

@jasnell didn't you suggest moving them to a json file?
IMHO if they are moving out they should go with their messages, and maybe after all migrations are done.

@starkwang starkwang closed this Jul 24, 2017
@jasnell

jasnell commented Jul 24, 2017

Copy link
Copy Markdown
Member

Eventually, yes, but these are fairly difficult to manage as it is. Once the migration is done we can revisit. I have a few things in mind already also...

@starkwang starkwang mentioned this pull request Aug 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Issues and PRs related to Node.js builds or CI infrastructure. doc Issues and PRs related to Node.js documentation. errors Issues and PRs related to JavaScript errors originating in Node.js core.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants