diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-04-02 03:46:17 +0200 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-04-04 12:51:03 +0200 |
commit | 3b044962c48fe313905877a96b5d0894a5404f6f (patch) | |
tree | f88086693fd685477a88b5cbc5c7442f25a49986 /lib/internal/crypto | |
parent | a9bf6652b5353f2098d4c0cd0eb77d17e02e164d (diff) | |
download | android-node-v8-3b044962c48fe313905877a96b5d0894a5404f6f.tar.gz android-node-v8-3b044962c48fe313905877a96b5d0894a5404f6f.tar.bz2 android-node-v8-3b044962c48fe313905877a96b5d0894a5404f6f.zip |
errors: add more information in case of invalid callbacks
This adds the actual callback that is passed through to the error
message in case an ERR_INVALID_CALLBACK error is thrown.
PR-URL: https://github.com/nodejs/node/pull/27048
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Diffstat (limited to 'lib/internal/crypto')
-rw-r--r-- | lib/internal/crypto/keygen.js | 2 | ||||
-rw-r--r-- | lib/internal/crypto/pbkdf2.js | 2 | ||||
-rw-r--r-- | lib/internal/crypto/random.js | 4 | ||||
-rw-r--r-- | lib/internal/crypto/scrypt.js | 2 |
4 files changed, 5 insertions, 5 deletions
diff --git a/lib/internal/crypto/keygen.js b/lib/internal/crypto/keygen.js index e212f6f451..cff58f15f2 100644 --- a/lib/internal/crypto/keygen.js +++ b/lib/internal/crypto/keygen.js @@ -46,7 +46,7 @@ function generateKeyPair(type, options, callback) { const impl = check(type, options); if (typeof callback !== 'function') - throw new ERR_INVALID_CALLBACK(); + throw new ERR_INVALID_CALLBACK(callback); const wrap = new AsyncWrap(Providers.KEYPAIRGENREQUEST); wrap.ondone = (ex, pubkey, privkey) => { diff --git a/lib/internal/crypto/pbkdf2.js b/lib/internal/crypto/pbkdf2.js index 4694c6ce9a..fc6341b83f 100644 --- a/lib/internal/crypto/pbkdf2.js +++ b/lib/internal/crypto/pbkdf2.js @@ -26,7 +26,7 @@ function pbkdf2(password, salt, iterations, keylen, digest, callback) { check(password, salt, iterations, keylen, digest)); if (typeof callback !== 'function') - throw new ERR_INVALID_CALLBACK(); + throw new ERR_INVALID_CALLBACK(callback); const encoding = getDefaultEncoding(); const keybuf = Buffer.alloc(keylen); diff --git a/lib/internal/crypto/random.js b/lib/internal/crypto/random.js index d26eab7559..257b00a9ce 100644 --- a/lib/internal/crypto/random.js +++ b/lib/internal/crypto/random.js @@ -47,7 +47,7 @@ function assertSize(size, elementSize, offset, length) { function randomBytes(size, cb) { size = assertSize(size, 1, 0, Infinity); if (cb !== undefined && typeof cb !== 'function') - throw new ERR_INVALID_CALLBACK(); + throw new ERR_INVALID_CALLBACK(cb); const buf = Buffer.alloc(size); @@ -95,7 +95,7 @@ function randomFill(buf, offset, size, cb) { cb = size; size = buf.byteLength - offset; } else if (typeof cb !== 'function') { - throw new ERR_INVALID_CALLBACK(); + throw new ERR_INVALID_CALLBACK(cb); } offset = assertOffset(offset, elementSize, buf.byteLength); diff --git a/lib/internal/crypto/scrypt.js b/lib/internal/crypto/scrypt.js index e3cc130c74..0ed4140c9c 100644 --- a/lib/internal/crypto/scrypt.js +++ b/lib/internal/crypto/scrypt.js @@ -32,7 +32,7 @@ function scrypt(password, salt, keylen, options, callback = defaults) { ({ password, salt, keylen } = options); if (typeof callback !== 'function') - throw new ERR_INVALID_CALLBACK(); + throw new ERR_INVALID_CALLBACK(callback); const encoding = getDefaultEncoding(); const keybuf = Buffer.alloc(keylen); |