From b38c81cb449a822ab45e6caa210d070b91a59836 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Mon, 19 Mar 2018 14:18:50 +0100 Subject: 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 Reviewed-By: Matteo Collina Reviewed-By: Joyee Cheung Reviewed-By: Anna Henningsen --- lib/internal/http2/compat.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/internal/http2/compat.js') 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; } -- cgit v1.2.3