diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2018-03-19 14:18:50 +0100 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2018-03-25 03:01:45 +0200 |
commit | b38c81cb449a822ab45e6caa210d070b91a59836 (patch) | |
tree | eb6fe75fa90a4f8829277a5c2382aaa8a958abf9 /lib/internal/http2/compat.js | |
parent | acc3c770e7717673ee87fa37076fc50fcb91e4ea (diff) | |
download | android-node-v8-b38c81cb449a822ab45e6caa210d070b91a59836.tar.gz android-node-v8-b38c81cb449a822ab45e6caa210d070b91a59836.tar.bz2 android-node-v8-b38c81cb449a822ab45e6caa210d070b91a59836.zip |
lib: improve error handling
This improves the error handling for a couple cases where the
received value would not have been handled so far or where the name
is wrong etc.
PR-URL: https://github.com/nodejs/node/pull/19445
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'lib/internal/http2/compat.js')
-rw-r--r-- | lib/internal/http2/compat.js | 7 |
1 files changed, 5 insertions, 2 deletions
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; } |