diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/_http_client.js | 5 | ||||
-rw-r--r-- | lib/_http_outgoing.js | 2 | ||||
-rw-r--r-- | lib/_tls_wrap.js | 3 | ||||
-rw-r--r-- | lib/buffer.js | 5 | ||||
-rw-r--r-- | lib/internal/http2/compat.js | 7 |
5 files changed, 15 insertions, 7 deletions
diff --git a/lib/_http_client.js b/lib/_http_client.js index 03c69a9306..5ab6d0bdba 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -87,8 +87,9 @@ function ClientRequest(options, cb) { // Explicitly pass through this statement as agent will not be used // when createConnection is provided. } else if (typeof agent.addRequest !== 'function') { - throw new ERR_INVALID_ARG_TYPE('Agent option', - ['Agent-like Object', 'undefined', 'false']); + throw new ERR_INVALID_ARG_TYPE('options.agent', + ['Agent-like Object', 'undefined', 'false'], + agent); } this.agent = agent; diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index 2af2fddb62..adc4481347 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -755,7 +755,7 @@ OutgoingMessage.prototype.end = function end(chunk, encoding, callback) { var uncork; if (chunk) { if (typeof chunk !== 'string' && !(chunk instanceof Buffer)) { - throw new ERR_INVALID_ARG_TYPE('first argument', ['string', 'Buffer']); + throw new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk); } if (!this._header) { if (typeof chunk === 'string') diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index 41dd001bd6..686e109ca3 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -908,7 +908,8 @@ function Server(options, listener) { this[kSNICallback] = options.SNICallback; if (typeof this[kHandshakeTimeout] !== 'number') { - throw new ERR_INVALID_ARG_TYPE('timeout', 'number'); + throw new ERR_INVALID_ARG_TYPE( + 'options.handshakeTimeout', 'number', options.handshakeTimeout); } if (this.sessionTimeout) { diff --git a/lib/buffer.js b/lib/buffer.js index a13ada73ce..45c1282f2d 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -461,7 +461,10 @@ Buffer.concat = function concat(list, length) { for (i = 0; i < list.length; i++) { var buf = list[i]; if (!isUint8Array(buf)) { - throw new ERR_INVALID_ARG_TYPE('list', ['Array', 'Buffer', 'Uint8Array']); + // TODO(BridgeAR): This should not be of type ERR_INVALID_ARG_TYPE. + // Instead, find the proper error code for this. + throw new ERR_INVALID_ARG_TYPE( + `list[${i}]`, ['Array', 'Buffer', 'Uint8Array'], list[i]); } _copy(buf, buffer, pos); pos += buf.length; diff --git a/lib/internal/http2/compat.js b/lib/internal/http2/compat.js index 78fedcb2ce..1a855f5bf0 100644 --- a/lib/internal/http2/compat.js +++ b/lib/internal/http2/compat.js @@ -13,6 +13,7 @@ const { ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED, ERR_HTTP2_STATUS_INVALID, ERR_INVALID_ARG_TYPE, + ERR_INVALID_ARG_VALUE, ERR_INVALID_CALLBACK, ERR_INVALID_HTTP_TOKEN } = require('internal/errors').codes; @@ -312,8 +313,10 @@ class Http2ServerRequest extends Readable { } set method(method) { - if (typeof method !== 'string' || method.trim() === '') - throw new ERR_INVALID_ARG_TYPE('method', 'string'); + if (typeof method !== 'string') + throw new ERR_INVALID_ARG_TYPE('method', 'string', method); + if (method.trim() === '') + throw new ERR_INVALID_ARG_VALUE('method', method); this[kHeaders][HTTP2_HEADER_METHOD] = method; } |