crypto: improve crypto error messages by thefourtheye · Pull Request #3100 · nodejs/node (original) (raw)

thefourtheye

Introduce a new MACRO to check if the data is a String object and
updated existing MACROs to include the actual object description to
be printed if there is an error.

cc @nodejs/crypto

@thefourtheye thefourtheye added crypto

Issues and PRs related to the crypto subsystem.

c++

Issues and PRs that require attention from people who are familiar with C++.

test

Issues and PRs related to the tests.

labels

Sep 28, 2015

YurySolovyov

@@ -818,7 +835,7 @@ void SecureContext::SetOptions(const FunctionCallbackInfo& args) {
SecureContext* sc = Unwrap(args.Holder());
if (args.Length() != 1 |
return sc->env()->ThrowTypeError("Bad parameter");
return sc->env()->ThrowTypeError("Options must be an integer value");

Choose a reason for hiding this comment

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

maybe "Parameter must be an integer value" ? since it looks like it is the only one possible param here

Choose a reason for hiding this comment

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

@YuriSolovyov Ya, that is why I left it as the function name hints. I don't have a strong opinion about this name anyway.

@thefourtheye

bnoordhuis

@@ -33,17 +33,24 @@
#define OPENSSL_CONST
#endif
#define THROW_AND_RETURN_IF_NOT_STRING_OR_BUFFER(val) \
#define THROW_AND_RETURN_IF_NOT_STRING_OR_BUFFER(val, obj) \

Choose a reason for hiding this comment

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

obj is a pretty bad name. Maybe call it prefix?

@thefourtheye

bnoordhuis

| if (args.Length() != 1 || !args[0]->IsString()) | | -------------------------------------------------------------------- | | return env->ThrowTypeError("First argument should be a string"); | | if (args.Length() != 1) | | return env->ThrowTypeError("ECDH Curve name argument is mandatory"); |

Choose a reason for hiding this comment

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

"ECDH curve name" here and below?

@bnoordhuis

Still quite a few places where words are Incongruously Capitalized.

@thefourtheye

@bnoordhuis Sorry, I think I misunderstood your initial comments. I just thought that names are inconsistent. I didn't think about the case. I hope I updated all the places properly this time. PTAL.

@thefourtheye

@thefourtheye

@jasnell

@jasnell jasnell added semver-major

PRs that contain breaking changes and should be released in the next major version.

and removed stalled

Issues and PRs that are stalled.

labels

Mar 26, 2016

@jasnell

semver-major because of the changes to the error messages.

@bnoordhuis

1 similar comment

@indutny

thefourtheye added a commit that referenced this pull request

Mar 26, 2016

@thefourtheye

Introduce a new MACRO to check if the data is a String object and update existing MACROs to include the actual object description to be printed in case of an error.

PR-URL: #3100 Reviewed-By: Ben Noordhuis info@bnoordhuis.nl Reviewed-By: Fedor Indutny fedor.indutny@gmail.com Reviewed-By: James M Snell jasnell@gmail.com

@thefourtheye

Thanks for the reviews :-) Landed in 41feaa8.

jasnell added a commit that referenced this pull request

Apr 26, 2016

@jasnell

The following significant (semver-major) changes have been made since the previous Node v5.0.0 release.

jasnell added a commit that referenced this pull request

Apr 26, 2016

@jasnell

The following significant (semver-major) changes have been made since the previous Node v5.0.0 release.

jasnell added a commit that referenced this pull request

Apr 26, 2016

@jasnell

The following significant (semver-major) changes have been made since the previous Node v5.0.0 release.

jasnell added a commit that referenced this pull request

Apr 26, 2016

@jasnell

The following significant (semver-major) changes have been made since the previous Node v5.0.0 release.

jasnell added a commit that referenced this pull request

Apr 26, 2016

@jasnell

The following significant (semver-major) changes have been made since the previous Node v5.0.0 release.