| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e8d4015 commit e4d641f
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -126,7 +126,8 @@ const { | |||
| 126 | 126 | validateNumber, | |
| 127 | 127 | validateString, | |
| 128 | 128 | validateUint32, | |
| 129 | - validateAbortSignal | ||
| 129 | + validateAbortSignal, | ||
| 130 | + validateBoolean, | ||
| 130 | 131 | } = require('internal/validators'); | |
| 131 | 132 | const fsPromisesInternal = require('internal/fs/promises'); | |
| 132 | 133 | const { utcDate } = require('internal/http'); | |
@@ -761,26 +762,26 @@ function requestOnConnect(headers, options) { | |||
| 761 | 762 | const setAndValidatePriorityOptions = hideStackFrames((options) => { | |
| 762 | 763 | if (options.weight === undefined) { | |
| 763 | 764 | options.weight = NGHTTP2_DEFAULT_WEIGHT; | |
| 764 | - } else if (typeof options.weight !== 'number') { | ||
| 765 | - throw new ERR_INVALID_ARG_VALUE('options.weight', options.weight); | ||
| 765 | + } else { | ||
| 766 | + validateNumber(options.weight, 'options.weight'); | ||
| 766 | 767 | } | |
| 767 | 768 | ||
| 768 | 769 | if (options.parent === undefined) { | |
| 769 | 770 | options.parent = 0; | |
| 770 | - } else if (typeof options.parent !== 'number' || options.parent < 0) { | ||
| 771 | - throw new ERR_INVALID_ARG_VALUE('options.parent', options.parent); | ||
| 771 | + } else { | ||
| 772 | + validateNumber(options.parent, 'options.parent', 0); | ||
| 772 | 773 | } | |
| 773 | 774 | ||
| 774 | 775 | if (options.exclusive === undefined) { | |
| 775 | 776 | options.exclusive = false; | |
| 776 | - } else if (typeof options.exclusive !== 'boolean') { | ||
| 777 | - throw new ERR_INVALID_ARG_VALUE('options.exclusive', options.exclusive); | ||
| 777 | + } else { | ||
| 778 | + validateBoolean(options.exclusive, 'options.exclusive'); | ||
| 778 | 779 | } | |
| 779 | 780 | ||
| 780 | 781 | if (options.silent === undefined) { | |
| 781 | 782 | options.silent = false; | |
| 782 | - } else if (typeof options.silent !== 'boolean') { | ||
| 783 | - throw new ERR_INVALID_ARG_VALUE('options.silent', options.silent); | ||
| 783 | + } else { | ||
| 784 | + validateBoolean(options.silent, 'options.silent'); | ||
| 784 | 785 | } | |
| 785 | 786 | }); | |
| 786 | 787 | ||
@@ -1784,8 +1785,8 @@ class ClientHttp2Session extends Http2Session { | |||
| 1784 | 1785 | // stream by default if the user has not specifically indicated a | |
| 1785 | 1786 | // preference. | |
| 1786 | 1787 | options.endStream = isPayloadMeaningless(headers[HTTP2_HEADER_METHOD]); | |
| 1787 | - } else if (typeof options.endStream !== 'boolean') { | ||
| 1788 | - throw new ERR_INVALID_ARG_VALUE('options.endStream', options.endStream); | ||
| 1788 | + } else { | ||
| 1789 | + validateBoolean(options.endStream, 'options.endStream'); | ||
| 1789 | 1790 | } | |
| 1790 | 1791 | ||
| 1791 | 1792 | const headersList = mapToHeaders(headers); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,7 +5,6 @@ if (!common.hasCrypto) | |||
| 5 | 5 | common.skip('missing crypto'); | |
| 6 | 6 | const assert = require('assert'); | |
| 7 | 7 | const http2 = require('http2'); | |
| 8 | - const { inspect } = require('util'); | ||
| 9 | 8 | ||
| 10 | 9 | // Check if correct errors are emitted when wrong type of data is passed | |
| 11 | 10 | // to certain options of ClientHttp2Session request method | |
@@ -48,9 +47,7 @@ server.listen(0, common.mustCall(() => { | |||
| 48 | 47 | [option]: types[type] | |
| 49 | 48 | }), { | |
| 50 | 49 | name: 'TypeError', | |
| 51 | - code: 'ERR_INVALID_ARG_VALUE', | ||
| 52 | - message: `The property 'options.${option}' is invalid. ` + | ||
| 53 | - `Received ${inspect(types[type])}` | ||
| 50 | + code: 'ERR_INVALID_ARG_TYPE', | ||
| 54 | 51 | }); | |
| 55 | 52 | }); | |
| 56 | 53 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments