| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a9a606f commit f22672d
9 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -908,7 +908,7 @@ function getValidStdio(stdio, sync) { | |||
| 908 | 908 | if (typeof stdio === 'string') { | |
| 909 | 909 | stdio = stdioStringToArray(stdio); | |
| 910 | 910 | } else if (!ArrayIsArray(stdio)) { | |
| 911 | - throw new ERR_INVALID_OPT_VALUE('stdio', inspect(stdio)); | ||
| 911 | + throw new ERR_INVALID_OPT_VALUE('stdio', stdio); | ||
| 912 | 912 | } | |
| 913 | 913 | ||
| 914 | 914 | // At least 3 stdio will be created | |
@@ -993,7 +993,7 @@ function getValidStdio(stdio, sync) { | |||
| 993 | 993 | } else { | |
| 994 | 994 | // Cleanup | |
| 995 | 995 | cleanup(); | |
| 996 | - throw new ERR_INVALID_OPT_VALUE('stdio', inspect(stdio)); | ||
| 996 | + throw new ERR_INVALID_OPT_VALUE('stdio', stdio); | ||
| 997 | 997 | } | |
| 998 | 998 | ||
| 999 | 999 | return acc; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1100,10 +1100,13 @@ E('ERR_INVALID_MODULE_SPECIFIER', (request, reason, base = undefined) => { | |||
| 1100 | 1100 | return `Invalid module "${request}" ${reason}${base ? | |
| 1101 | 1101 | ` imported from ${base}` : ''}`; | |
| 1102 | 1102 | }, TypeError); | |
| 1103 | - E('ERR_INVALID_OPT_VALUE', (name, value) => | ||
| 1104 | - `The value "${String(value)}" is invalid for option "${name}"`, | ||
| 1105 | - TypeError, | ||
| 1106 | - RangeError); | ||
| 1103 | + E('ERR_INVALID_OPT_VALUE', (name, value, reason = '') => { | ||
| 1104 | + let inspected = typeof value === 'string' ? | ||
| 1105 | + value : lazyInternalUtilInspect().inspect(value); | ||
| 1106 | + if (inspected.length > 128) inspected = `${inspected.slice(0, 128)}...`; | ||
| 1107 | + if (reason) reason = '. ' + reason; | ||
| 1108 | + return `The value "${inspected}" is invalid for option "${name}"` + reason; | ||
| 1109 | + }, TypeError, RangeError); | ||
| 1107 | 1110 | E('ERR_INVALID_OPT_VALUE_ENCODING', | |
| 1108 | 1111 | 'The value "%s" is invalid for option "encoding"', TypeError); | |
| 1109 | 1112 | E('ERR_INVALID_PACKAGE_CONFIG', (path, base, message) => { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,7 +34,6 @@ const { | |||
| 34 | 34 | ||
| 35 | 35 | const EventEmitter = require('events'); | |
| 36 | 36 | const stream = require('stream'); | |
| 37 | - const { inspect } = require('internal/util/inspect'); | ||
| 38 | 37 | let debug = require('internal/util/debuglog').debuglog('net', (fn) => { | |
| 39 | 38 | debug = fn; | |
| 40 | 39 | }); | |
@@ -1489,7 +1488,7 @@ Server.prototype.listen = function(...args) { | |||
| 1489 | 1488 | 'must have the property "port" or "path"'); | |
| 1490 | 1489 | } | |
| 1491 | 1490 | ||
| 1492 | - throw new ERR_INVALID_OPT_VALUE('options', inspect(options)); | ||
| 1491 | + throw new ERR_INVALID_OPT_VALUE('options', options); | ||
| 1493 | 1492 | }; | |
| 1494 | 1493 | ||
| 1495 | 1494 | function lookupAndListen(self, port, address, backlog, exclusive, flags) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,7 +16,7 @@ const { | |||
| 16 | 16 | sign, | |
| 17 | 17 | verify | |
| 18 | 18 | } = require('crypto'); | |
| 19 | - const { promisify } = require('util'); | ||
| 19 | + const { inspect, promisify } = require('util'); | ||
| 20 | 20 | ||
| 21 | 21 | // Asserts that the size of the given key (in chars or bytes) is within 10% of | |
| 22 | 22 | // the expected size. | |
@@ -705,13 +705,14 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher); | |||
| 705 | 705 | }), { | |
| 706 | 706 | name: 'TypeError', | |
| 707 | 707 | code: 'ERR_INVALID_OPT_VALUE', | |
| 708 | - message: `The value "${type}" is invalid for option ` + | ||
| 708 | + message: `The value "${inspect(type)}" is invalid for option ` + | ||
| 709 | 709 | '"publicKeyEncoding.type"' | |
| 710 | 710 | }); | |
| 711 | 711 | } | |
| 712 | 712 | ||
| 713 | 713 | // Missing / invalid publicKeyEncoding.format. | |
| 714 | 714 | for (const format of [undefined, null, 0, false, 'a', {}]) { | |
| 715 | + const expected = typeof format === 'string' ? format : inspect(format); | ||
| 715 | 716 | assert.throws(() => generateKeyPairSync('rsa', { | |
| 716 | 717 | modulusLength: 4096, | |
| 717 | 718 | publicKeyEncoding: { | |
@@ -725,7 +726,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher); | |||
| 725 | 726 | }), { | |
| 726 | 727 | name: 'TypeError', | |
| 727 | 728 | code: 'ERR_INVALID_OPT_VALUE', | |
| 728 | - message: `The value "${format}" is invalid for option ` + | ||
| 729 | + message: `The value "${expected}" is invalid for option ` + | ||
| 729 | 730 | '"publicKeyEncoding.format"' | |
| 730 | 731 | }); | |
| 731 | 732 | } | |
@@ -761,13 +762,14 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher); | |||
| 761 | 762 | }), { | |
| 762 | 763 | name: 'TypeError', | |
| 763 | 764 | code: 'ERR_INVALID_OPT_VALUE', | |
| 764 | - message: `The value "${type}" is invalid for option ` + | ||
| 765 | + message: `The value "${inspect(type)}" is invalid for option ` + | ||
| 765 | 766 | '"privateKeyEncoding.type"' | |
| 766 | 767 | }); | |
| 767 | 768 | } | |
| 768 | 769 | ||
| 769 | 770 | // Missing / invalid privateKeyEncoding.format. | |
| 770 | 771 | for (const format of [undefined, null, 0, false, 'a', {}]) { | |
| 772 | + const expected = typeof format === 'string' ? format : inspect(format); | ||
| 771 | 773 | assert.throws(() => generateKeyPairSync('rsa', { | |
| 772 | 774 | modulusLength: 4096, | |
| 773 | 775 | publicKeyEncoding: { | |
@@ -781,7 +783,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher); | |||
| 781 | 783 | }), { | |
| 782 | 784 | name: 'TypeError', | |
| 783 | 785 | code: 'ERR_INVALID_OPT_VALUE', | |
| 784 | - message: `The value "${format}" is invalid for option ` + | ||
| 786 | + message: `The value "${expected}" is invalid for option ` + | ||
| 785 | 787 | '"privateKeyEncoding.format"' | |
| 786 | 788 | }); | |
| 787 | 789 | } | |
@@ -802,7 +804,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher); | |||
| 802 | 804 | }), { | |
| 803 | 805 | name: 'TypeError', | |
| 804 | 806 | code: 'ERR_INVALID_OPT_VALUE', | |
| 805 | - message: `The value "${cipher}" is invalid for option ` + | ||
| 807 | + message: `The value "${inspect(cipher)}" is invalid for option ` + | ||
| 806 | 808 | '"privateKeyEncoding.cipher"' | |
| 807 | 809 | }); | |
| 808 | 810 | } | |
@@ -865,25 +867,29 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher); | |||
| 865 | 867 | { | |
| 866 | 868 | // Test invalid modulus lengths. | |
| 867 | 869 | for (const modulusLength of [undefined, null, 'a', true, {}, [], 512.1, -1]) { | |
| 870 | + const expected = typeof modulusLength === 'string' ? | ||
| 871 | + modulusLength : inspect(modulusLength); | ||
| 868 | 872 | assert.throws(() => generateKeyPair('rsa', { | |
| 869 | 873 | modulusLength | |
| 870 | 874 | }), { | |
| 871 | 875 | name: 'TypeError', | |
| 872 | 876 | code: 'ERR_INVALID_OPT_VALUE', | |
| 873 | - message: `The value "${modulusLength}" is invalid for option ` + | ||
| 877 | + message: `The value "${expected}" is invalid for option ` + | ||
| 874 | 878 | '"modulusLength"' | |
| 875 | 879 | }); | |
| 876 | 880 | } | |
| 877 | 881 | ||
| 878 | 882 | // Test invalid exponents. | |
| 879 | 883 | for (const publicExponent of ['a', true, {}, [], 3.5, -1]) { | |
| 884 | + const expected = typeof publicExponent === 'string' ? | ||
| 885 | + publicExponent : inspect(publicExponent); | ||
| 880 | 886 | assert.throws(() => generateKeyPair('rsa', { | |
| 881 | 887 | modulusLength: 4096, | |
| 882 | 888 | publicExponent | |
| 883 | 889 | }), { | |
| 884 | 890 | name: 'TypeError', | |
| 885 | 891 | code: 'ERR_INVALID_OPT_VALUE', | |
| 886 | - message: `The value "${publicExponent}" is invalid for option ` + | ||
| 892 | + message: `The value "${expected}" is invalid for option ` + | ||
| 887 | 893 | '"publicExponent"' | |
| 888 | 894 | }); | |
| 889 | 895 | } | |
@@ -893,25 +899,29 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher); | |||
| 893 | 899 | { | |
| 894 | 900 | // Test invalid modulus lengths. | |
| 895 | 901 | for (const modulusLength of [undefined, null, 'a', true, {}, [], 4096.1]) { | |
| 902 | + const expected = typeof modulusLength === 'string' ? | ||
| 903 | + modulusLength : inspect(modulusLength); | ||
| 896 | 904 | assert.throws(() => generateKeyPair('dsa', { | |
| 897 | 905 | modulusLength | |
| 898 | 906 | }), { | |
| 899 | 907 | name: 'TypeError', | |
| 900 | 908 | code: 'ERR_INVALID_OPT_VALUE', | |
| 901 | - message: `The value "${modulusLength}" is invalid for option ` + | ||
| 909 | + message: `The value "${expected}" is invalid for option ` + | ||
| 902 | 910 | '"modulusLength"' | |
| 903 | 911 | }); | |
| 904 | 912 | } | |
| 905 | 913 | ||
| 906 | 914 | // Test invalid divisor lengths. | |
| 907 | 915 | for (const divisorLength of ['a', true, {}, [], 4096.1]) { | |
| 916 | + const expected = typeof divisorLength === 'string' ? | ||
| 917 | + divisorLength : inspect(divisorLength); | ||
| 908 | 918 | assert.throws(() => generateKeyPair('dsa', { | |
| 909 | 919 | modulusLength: 2048, | |
| 910 | 920 | divisorLength | |
| 911 | 921 | }), { | |
| 912 | 922 | name: 'TypeError', | |
| 913 | 923 | code: 'ERR_INVALID_OPT_VALUE', | |
| 914 | - message: `The value "${divisorLength}" is invalid for option ` + | ||
| 924 | + message: `The value "${expected}" is invalid for option ` + | ||
| 915 | 925 | '"divisorLength"' | |
| 916 | 926 | }); | |
| 917 | 927 | } | |
@@ -942,7 +952,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher); | |||
| 942 | 952 | }, { | |
| 943 | 953 | name: 'TypeError', | |
| 944 | 954 | code: 'ERR_INVALID_OPT_VALUE', | |
| 945 | - message: `The value "${namedCurve}" is invalid for option ` + | ||
| 955 | + message: `The value "${inspect(namedCurve)}" is invalid for option ` + | ||
| 946 | 956 | '"namedCurve"' | |
| 947 | 957 | }); | |
| 948 | 958 | } | |
@@ -1079,7 +1089,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher); | |||
| 1079 | 1089 | }, { | |
| 1080 | 1090 | name: 'TypeError', | |
| 1081 | 1091 | code: 'ERR_INVALID_OPT_VALUE', | |
| 1082 | - message: `The value "${hashValue}" is invalid for option "hash"` | ||
| 1092 | + message: `The value "${inspect(hashValue)}" is invalid for option "hash"` | ||
| 1083 | 1093 | }); | |
| 1084 | 1094 | } | |
| 1085 | 1095 | ||
@@ -1182,6 +1192,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher); | |||
| 1182 | 1192 | ); | |
| 1183 | 1193 | ||
| 1184 | 1194 | for (const mgf1Hash of [null, 0, false, {}, []]) { | |
| 1195 | + const expected = inspect(mgf1Hash); | ||
| 1185 | 1196 | assert.throws( | |
| 1186 | 1197 | () => { | |
| 1187 | 1198 | generateKeyPair('rsa-pss', { | |
@@ -1194,7 +1205,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher); | |||
| 1194 | 1205 | { | |
| 1195 | 1206 | name: 'TypeError', | |
| 1196 | 1207 | code: 'ERR_INVALID_OPT_VALUE', | |
| 1197 | - message: `The value "${mgf1Hash}" is invalid for option "mgf1Hash"` | ||
| 1208 | + message: `The value "${expected}" is invalid for option "mgf1Hash"` | ||
| 1198 | 1209 | } | |
| 1199 | 1210 | ); | |
| 1200 | 1211 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,7 @@ 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'); | ||
| 8 | 9 | ||
| 9 | 10 | // Check if correct errors are emitted when wrong type of data is passed | |
| 10 | 11 | // to certain options of ClientHttp2Session request method | |
@@ -48,7 +49,7 @@ server.listen(0, common.mustCall(() => { | |||
| 48 | 49 | }), { | |
| 49 | 50 | name: 'TypeError', | |
| 50 | 51 | code: 'ERR_INVALID_OPT_VALUE', | |
| 51 | - message: `The value "${String(types[type])}" is invalid ` + | ||
| 52 | + message: `The value "${inspect(types[type])}" is invalid ` + | ||
| 52 | 53 | `for option "${option}"` | |
| 53 | 54 | }); | |
| 54 | 55 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,6 +6,7 @@ if (!common.hasCrypto) | |||
| 6 | 6 | const fixtures = require('../common/fixtures'); | |
| 7 | 7 | const assert = require('assert'); | |
| 8 | 8 | const http2 = require('http2'); | |
| 9 | + const { inspect } = require('util'); | ||
| 9 | 10 | ||
| 10 | 11 | const optionsWithTypeError = { | |
| 11 | 12 | offset: 'number', | |
@@ -45,7 +46,7 @@ server.on('stream', common.mustCall((stream) => { | |||
| 45 | 46 | { | |
| 46 | 47 | name: 'TypeError', | |
| 47 | 48 | code: 'ERR_INVALID_OPT_VALUE', | |
| 48 | - message: `The value "${String(types[type])}" is invalid ` + | ||
| 49 | + message: `The value "${inspect(types[type])}" is invalid ` + | ||
| 49 | 50 | `for option "${option}"` | |
| 50 | 51 | } | |
| 51 | 52 | ); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,7 @@ const fixtures = require('../common/fixtures'); | |||
| 7 | 7 | const assert = require('assert'); | |
| 8 | 8 | const http2 = require('http2'); | |
| 9 | 9 | const fs = require('fs'); | |
| 10 | + const { inspect } = require('util'); | ||
| 10 | 11 | ||
| 11 | 12 | const optionsWithTypeError = { | |
| 12 | 13 | offset: 'number', | |
@@ -65,7 +66,7 @@ server.on('stream', common.mustCall((stream) => { | |||
| 65 | 66 | { | |
| 66 | 67 | name: 'TypeError', | |
| 67 | 68 | code: 'ERR_INVALID_OPT_VALUE', | |
| 68 | - message: `The value "${String(types[type])}" is invalid ` + | ||
| 69 | + message: `The value "${inspect(types[type])}" is invalid ` + | ||
| 69 | 70 | `for option "${option}"` | |
| 70 | 71 | } | |
| 71 | 72 | ); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -58,7 +58,7 @@ assert.strictEqual(counts[NODE_PERFORMANCE_ENTRY_TYPE_FUNCTION], 0); | |||
| 58 | 58 | { | |
| 59 | 59 | code: 'ERR_INVALID_OPT_VALUE', | |
| 60 | 60 | name: 'TypeError', | |
| 61 | - message: `The value "${i}" is invalid ` + | ||
| 61 | + message: `The value "${inspect(i)}" is invalid ` + | ||
| 62 | 62 | 'for option "entryTypes"' | |
| 63 | 63 | }); | |
| 64 | 64 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,6 +3,7 @@ const common = require('../common'); | |||
| 3 | 3 | ||
| 4 | 4 | const assert = require('assert'); | |
| 5 | 5 | const stream = require('stream'); | |
| 6 | + const { inspect } = require('util'); | ||
| 6 | 7 | ||
| 7 | 8 | { | |
| 8 | 9 | // This test ensures that the stream implementation correctly handles values | |
@@ -20,14 +21,16 @@ const stream = require('stream'); | |||
| 20 | 21 | assert.strictEqual(writable._writableState.highWaterMark, ovfl); | |
| 21 | 22 | ||
| 22 | 23 | for (const invalidHwm of [true, false, '5', {}, -5, NaN]) { | |
| 24 | + const expected = typeof invalidHwm === 'string' ? | ||
| 25 | + invalidHwm : inspect(invalidHwm); | ||
| 23 | 26 | for (const type of [stream.Readable, stream.Writable]) { | |
| 24 | 27 | assert.throws(() => { | |
| 25 | 28 | type({ highWaterMark: invalidHwm }); | |
| 26 | 29 | }, { | |
| 27 | 30 | name: 'TypeError', | |
| 28 | 31 | code: 'ERR_INVALID_OPT_VALUE', | |
| 29 | 32 | message: | |
| 30 | - `The value "${invalidHwm}" is invalid for option "highWaterMark"` | ||
| 33 | + `The value "${expected}" is invalid for option "highWaterMark"` | ||
| 31 | 34 | }); | |
| 32 | 35 | } | |
| 33 | 36 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments