Skip to content

src: add error codes to errors thrown in C++ - #27700

Closed
yanivfriedensohn wants to merge 1 commit into
nodejs:masterfrom
yanivfriedensohn:add-error-codes-to-errors
Closed

yanivfriedensohn wants to merge 1 commit into
nodejs:masterfrom
yanivfriedensohn:add-error-codes-to-errors

Conversation

@yanivfriedensohn

Copy link
Copy Markdown

This PR follows #20121 and adds error codes to a few errors thrown in C++.

Moreover, InlineDecoder::Decode has been refactored to avoid throwing an exception related to StringBytes::IsValidString inside the Decode method.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. labels May 14, 2019
@yanivfriedensohn
yanivfriedensohn force-pushed the add-error-codes-to-errors branch from 656e764 to dcfd8a9 Compare May 14, 2019 20:35
@sam-github
sam-github requested review from addaleax and tniessen May 14, 2019 22:37
@sam-github

Copy link
Copy Markdown
Contributor

Adding .code looks good to me, but I'm not familar enough with these APIs to see if this is semver-major or not, or if this is the correct way to handle string encoding.

@jasnell jasnell added the semver-major PRs that contain breaking changes and should be released in the next major version. label May 18, 2019
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Comment thread src/node_buffer.cc Resolved
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Comment thread test/parallel/test-crypto.js Resolved
Comment thread src/node_crypto.cc Resolved
Comment thread src/node_crypto.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.

This seems like an anti-pattern to me. You are effectively moving error handling from Decode() to different places, however, ParseEncoding is now called in multiple different places, too.

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.

We prefer throwing the JS exception in the binding instead of in nested C++ functions.

Ideally this should be done in JS land, though.

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.

Moving error handling out is okay as long as the callee still properly checks parameters. Your comment below would mitigate the problem :)

ghost May 24, 2019

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I moved the error handling to the binding.

Comment thread src/string_bytes.h Resolved
@yanivfriedensohn
yanivfriedensohn force-pushed the add-error-codes-to-errors branch from 96aa81f to 6b94e80 Compare May 24, 2019 13:37
Comment thread lib/buffer.js Resolved
Comment thread src/string_bytes.cc Resolved
@yanivfriedensohn
yanivfriedensohn force-pushed the add-error-codes-to-errors branch 5 times, most recently from 53ddb82 to 487f8fe Compare May 26, 2019 20:51
@nodejs-github-bot

ghost commented May 27, 2019

Copy link
Copy Markdown
Collaborator

Comment thread lib/internal/util.js Resolved
@nodejs-github-bot

ghost commented May 28, 2019

Copy link
Copy Markdown
Collaborator

@yanivfriedensohn

ghost commented Jun 4, 2019

Copy link
Copy Markdown
Author

@tniessen @joyeecheung pinging to check if the open conversations can be resolved.

ghost 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 with nits

Comment thread src/node_crypto.cc Resolved
Comment thread src/node_crypto.cc Resolved
Comment thread src/node_crypto.cc Resolved
Comment thread src/string_bytes.cc Resolved
@yanivfriedensohn

ghost commented Jun 14, 2019

Copy link
Copy Markdown
Author

@tniessen @addaleax pinging to check if this PR can be approved.

@nodejs-github-bot

ghost commented Jun 27, 2019

Copy link
Copy Markdown
Collaborator

@joyeecheung joyeecheung added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Jun 27, 2019
@nodejs-github-bot

ghost commented Jun 27, 2019

Copy link
Copy Markdown
Collaborator

@joyeecheung

ghost commented Jun 27, 2019

Copy link
Copy Markdown
Member

Jenkins is unable to rebase this PR onto master. @yanivfriedensohn can you rebase locally and push to the PR branch?

@yanivfriedensohn
yanivfriedensohn force-pushed the add-error-codes-to-errors branch from a612713 to 1404066 Compare June 28, 2019 08:11
@yanivfriedensohn

ghost commented Jun 28, 2019

Copy link
Copy Markdown
Author

I squashed the commits to avoid merge conflicts and then rebased onto master.

@nodejs-github-bot

ghost commented Jul 1, 2019

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

ghost commented Jul 5, 2019

Copy link
Copy Markdown
Collaborator

@yanivfriedensohn

ghost commented Jul 13, 2019

Copy link
Copy Markdown
Author

@Trott the failed tests doesn't seem to be related to the changes of this PR. Can we rerun the CI process?

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@Trott
Trott force-pushed the add-error-codes-to-errors branch from 1404066 to 9b64d06 Compare August 8, 2019 17:05
@Trott

ghost commented Aug 8, 2019

Copy link
Copy Markdown
Member

Rebased and force-pushed to get rid of the conflict.

@nodejs-github-bot

ghost commented Aug 8, 2019 •

Copy link
Copy Markdown
Collaborator

@Trott

ghost commented Aug 8, 2019

Copy link
Copy Markdown
Member

CITGM (this PR): https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/1938/
CITGM (master): https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/1939/

The above are queued. They will 404 until a worker is available.

@Trott

ghost commented Aug 8, 2019

Copy link
Copy Markdown
Member

CI is good and I'll be surprised if CITGM turns up anything. Could use a few more reviews, though. @nodejs/tsc

Comment thread lib/internal/validators.js Resolved

ghost 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

@Trott

ghost commented Aug 9, 2019

Copy link
Copy Markdown
Member

Landed in a0e2c6d.

Thanks for the contribution! πŸŽ‰

@Trott Trott closed this Aug 9, 2019
@yanivfriedensohn
yanivfriedensohn deleted the add-error-codes-to-errors branch August 10, 2019 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. 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.

10 participants