| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8ca9338 commit 1698c8e
9 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -225,10 +225,8 @@ function writeHead(statusCode, reason, obj) { | |||
| 225 | 225 | headers = obj; | |
| 226 | 226 | } | |
| 227 | 227 | ||
| 228 | - if (common._checkInvalidHeaderChar(this.statusMessage)) { | ||
| 229 | - throw new errors.Error('ERR_HTTP_INVALID_CHAR', | ||
| 230 | - 'Invalid character in statusMessage.'); | ||
| 231 | - } | ||
| 228 | + if (common._checkInvalidHeaderChar(this.statusMessage)) | ||
| 229 | + throw new errors.Error('ERR_INVALID_CHAR', 'statusMessage'); | ||
| 232 | 230 | ||
| 233 | 231 | var statusLine = 'HTTP/1.1 ' + statusCode + ' ' + this.statusMessage + CRLF; | |
| 234 | 232 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -77,8 +77,7 @@ function afterTransform(er, data) { | |||
| 77 | 77 | var cb = ts.writecb; | |
| 78 | 78 | ||
| 79 | 79 | if (!cb) { | |
| 80 | - return this.emit('error', | ||
| 81 | - new errors.Error('ERR_TRANSFORM_MULTIPLE_CALLBACK')); | ||
| 80 | + return this.emit('error', new errors.Error('ERR_MULTIPLE_CALLBACK')); | ||
| 82 | 81 | } | |
| 83 | 82 | ||
| 84 | 83 | ts.writechunk = null; | |
@@ -207,6 +206,7 @@ function done(stream, er, data) { | |||
| 207 | 206 | if (data != null) // single equals check for both `null` and `undefined` | |
| 208 | 207 | stream.push(data); | |
| 209 | 208 | ||
| 209 | + // TODO(BridgeAR): Write a test for these two error cases | ||
| 210 | 210 | // if there's nothing in the write buffer, then that means | |
| 211 | 211 | // that nothing more will ever be provided | |
| 212 | 212 | if (stream._writableState.length) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -110,32 +110,32 @@ module.exports = exports = { | |||
| 110 | 110 | // | |
| 111 | 111 | // Note: Please try to keep these in alphabetical order | |
| 112 | 112 | E('ERR_ARG_NOT_ITERABLE', '%s must be iterable'); | |
| 113 | - E('ERR_ASSERTION', (msg) => msg); | ||
| 113 | + E('ERR_ASSERTION', '%s'); | ||
| 114 | 114 | E('ERR_CONSOLE_WRITABLE_STREAM', | |
| 115 | - (name) => `Console expects a writable stream instance for ${name}`); | ||
| 116 | - E('ERR_CPU_USAGE', (errMsg) => `Unable to obtain cpu usage ${errMsg}`); | ||
| 115 | + 'Console expects a writable stream instance for %s'); | ||
| 116 | + E('ERR_CPU_USAGE', 'Unable to obtain cpu usage %s'); | ||
| 117 | 117 | E('ERR_FALSY_VALUE_REJECTION', 'Promise was rejected with falsy value'); | |
| 118 | 118 | E('ERR_HTTP_HEADERS_SENT', | |
| 119 | 119 | 'Cannot render headers after they are sent to the client'); | |
| 120 | - E('ERR_HTTP_INVALID_CHAR', 'Invalid character in statusMessage.'); | ||
| 121 | - E('ERR_HTTP_INVALID_STATUS_CODE', | ||
| 122 | - (originalStatusCode) => `Invalid status code: ${originalStatusCode}`); | ||
| 120 | + E('ERR_HTTP_INVALID_STATUS_CODE', 'Invalid status code: %s'); | ||
| 121 | + E('ERR_HTTP_TRAILER_INVALID', | ||
| 122 | + 'Trailers are invalid with this transfer encoding'); | ||
| 123 | 123 | E('ERR_INDEX_OUT_OF_RANGE', 'Index out of range'); | |
| 124 | + E('ERR_INVALID_ARG_TYPE', invalidArgType); | ||
| 124 | 125 | E('ERR_INVALID_ARRAY_LENGTH', | |
| 125 | 126 | (name, length, actual) => { | |
| 126 | - let msg = `The "${name}" array must have a length of ${length}`; | ||
| 127 | - if (arguments.length > 2) { | ||
| 128 | - const len = Array.isArray(actual) ? actual.length : actual; | ||
| 129 | - msg += `. Received length ${len}`; | ||
| 130 | - } | ||
| 131 | - return msg; | ||
| 127 | + const assert = lazyAssert(); | ||
| 128 | + assert.strictEqual(typeof actual, 'number'); | ||
| 129 | + return `The "${name}" array must have a length of ${ | ||
| 130 | + length}. Received length ${actual}`; | ||
| 132 | 131 | }); | |
| 133 | - E('ERR_INVALID_ARG_TYPE', invalidArgType); | ||
| 134 | - E('ERR_INVALID_CALLBACK', 'callback must be a function'); | ||
| 135 | - E('ERR_INVALID_FD', (fd) => `"fd" must be a positive integer: ${fd}`); | ||
| 132 | + E('ERR_INVALID_CALLBACK', 'Callback must be a function'); | ||
| 133 | + E('ERR_INVALID_CHAR', 'Invalid character in %s'); | ||
| 136 | 134 | E('ERR_INVALID_CURSOR_POS', | |
| 137 | 135 | 'Cannot set cursor row without setting its column'); | |
| 138 | - E('ERR_INVALID_FILE_URL_HOST', 'File URL host %s'); | ||
| 136 | + E('ERR_INVALID_FD', '"fd" must be a positive integer: %s'); | ||
| 137 | + E('ERR_INVALID_FILE_URL_HOST', | ||
| 138 | + 'File URL host must be "localhost" or empty on %s'); | ||
| 139 | 139 | E('ERR_INVALID_FILE_URL_PATH', 'File URL path %s'); | |
| 140 | 140 | E('ERR_INVALID_HANDLE_TYPE', 'This handle type cannot be sent'); | |
| 141 | 141 | E('ERR_INVALID_OPT_VALUE', | |
@@ -144,47 +144,42 @@ E('ERR_INVALID_OPT_VALUE', | |||
| 144 | 144 | }); | |
| 145 | 145 | E('ERR_INVALID_REPL_EVAL_CONFIG', | |
| 146 | 146 | 'Cannot specify both "breakEvalOnSigint" and "eval" for REPL'); | |
| 147 | + E('ERR_INVALID_REPL_HISTORY', 'Expected array, got %s'); | ||
| 147 | 148 | E('ERR_INVALID_SYNC_FORK_INPUT', | |
| 148 | - (value) => { | ||
| 149 | - return 'Asynchronous forks do not support Buffer, Uint8Array or string' + | ||
| 150 | - `input: ${value}`; | ||
| 151 | - }); | ||
| 149 | + 'Asynchronous forks do not support Buffer, Uint8Array or string input: %s'); | ||
| 152 | 150 | E('ERR_INVALID_THIS', 'Value of "this" must be of type %s'); | |
| 153 | 151 | E('ERR_INVALID_TUPLE', '%s must be an iterable %s tuple'); | |
| 154 | 152 | E('ERR_INVALID_URL', 'Invalid URL: %s'); | |
| 155 | 153 | E('ERR_INVALID_URL_SCHEME', | |
| 156 | - (expected) => `The URL must be ${oneOf(expected, 'scheme')}`); | ||
| 157 | - E('ERR_INVALID_REPL_HISTORY', | ||
| 158 | - (repl_history) => `Expected array, got ${repl_history}`); | ||
| 159 | - E('ERR_IPC_CHANNEL_CLOSED', 'channel closed'); | ||
| 154 | + (expected) => { | ||
| 155 | + lazyAssert(); | ||
| 156 | + return `The URL must be ${oneOf(expected, 'scheme')}`; | ||
| 157 | + }); | ||
| 158 | + E('ERR_IPC_CHANNEL_CLOSED', 'Channel closed'); | ||
| 160 | 159 | E('ERR_IPC_DISCONNECTED', 'IPC channel is already disconnected'); | |
| 161 | 160 | E('ERR_IPC_ONE_PIPE', 'Child process can have only one IPC pipe'); | |
| 162 | 161 | E('ERR_IPC_SYNC_FORK', 'IPC cannot be used with synchronous forks'); | |
| 163 | 162 | E('ERR_MISSING_ARGS', missingArgs); | |
| 164 | - E('ERR_PARSE_HISTORY_DATA', | ||
| 165 | - (oldHistoryPath) => `Could not parse history data in ${oldHistoryPath}`); | ||
| 163 | + E('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times'); | ||
| 166 | 164 | E('ERR_NO_CRYPTO', 'Node.js is not compiled with OpenSSL crypto support'); | |
| 165 | + E('ERR_PARSE_HISTORY_DATA', 'Could not parse history data in %s'); | ||
| 166 | + E('ERR_SOCKET_ALREADY_BOUND', 'Socket is already bound'); | ||
| 167 | + E('ERR_SOCKET_BAD_TYPE', | ||
| 168 | + 'Bad socket type specified. Valid types are: udp4, udp6'); | ||
| 169 | + E('ERR_SOCKET_CANNOT_SEND', 'Unable to send data'); | ||
| 170 | + E('ERR_SOCKET_BAD_PORT', 'Port should be > 0 and < 65536'); | ||
| 171 | + E('ERR_SOCKET_DGRAM_NOT_RUNNING', 'Not running'); | ||
| 167 | 172 | E('ERR_STDERR_CLOSE', 'process.stderr cannot be closed'); | |
| 168 | 173 | E('ERR_STDOUT_CLOSE', 'process.stdout cannot be closed'); | |
| 169 | 174 | E('ERR_STREAM_HAS_STRINGDECODER', 'Stream has StringDecoder'); | |
| 170 | 175 | E('ERR_TRANSFORM_ALREADY_TRANSFORMING', | |
| 171 | 176 | 'Calling transform done when still transforming'); | |
| 172 | - E('ERR_TRANSFORM_MULTIPLE_CALLBACK', 'Callback called multiple times'); | ||
| 173 | 177 | E('ERR_TRANSFORM_WITH_LENGTH_0', | |
| 174 | - 'Calling transform done when ws.length != 0'); | ||
| 175 | - E('ERR_HTTP_TRAILER_INVALID', | ||
| 176 | - 'Trailers are invalid with this transfer encoding'); | ||
| 177 | - E('ERR_UNKNOWN_BUILTIN_MODULE', (id) => `No such built-in module: ${id}`); | ||
| 178 | - E('ERR_UNKNOWN_SIGNAL', (signal) => `Unknown signal: ${signal}`); | ||
| 178 | + 'Calling transform done when writableState.length != 0'); | ||
| 179 | + E('ERR_UNKNOWN_SIGNAL', 'Unknown signal: %s'); | ||
| 179 | 180 | E('ERR_UNKNOWN_STDIN_TYPE', 'Unknown stdin file type'); | |
| 180 | 181 | E('ERR_UNKNOWN_STREAM_TYPE', 'Unknown stream file type'); | |
| 181 | - E('ERR_SOCKET_ALREADY_BOUND', 'Socket is already bound'); | ||
| 182 | - E('ERR_SOCKET_BAD_TYPE', | ||
| 183 | - 'Bad socket type specified. Valid types are: udp4, udp6'); | ||
| 184 | - E('ERR_SOCKET_CANNOT_SEND', 'Unable to send data'); | ||
| 185 | - E('ERR_SOCKET_BAD_PORT', 'Port should be > 0 and < 65536'); | ||
| 186 | - E('ERR_SOCKET_DGRAM_NOT_RUNNING', 'Not running'); | ||
| 187 | - E('ERR_V8BREAKITERATOR', 'full ICU data not installed. ' + | ||
| 182 | + E('ERR_V8BREAKITERATOR', 'Full ICU data not installed. ' + | ||
| 188 | 183 | 'See https://github.com/nodejs/node/wiki/Intl'); | |
| 189 | 184 | // Add new errors from here... | |
| 190 | 185 | ||
@@ -200,6 +195,7 @@ function invalidArgType(name, expected, actual) { | |||
| 200 | 195 | } | |
| 201 | 196 | ||
| 202 | 197 | function missingArgs(...args) { | |
| 198 | + const assert = lazyAssert(); | ||
| 203 | 199 | assert(args.length > 0, 'At least one arg needs to be specified'); | |
| 204 | 200 | let msg = 'The '; | |
| 205 | 201 | const len = args.length; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -86,7 +86,7 @@ function setup_hrtime() { | |||
| 86 | 86 | } | |
| 87 | 87 | if (time.length !== 2) { | |
| 88 | 88 | throw new errors.TypeError('ERR_INVALID_ARRAY_LENGTH', 'time', 2, | |
| 89 | - time); | ||
| 89 | + time.length); | ||
| 90 | 90 | } | |
| 91 | 91 | ||
| 92 | 92 | const sec = (hrValues[0] * 0x100000000 + hrValues[1]) - time[0]; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1352,8 +1352,7 @@ function getPathFromURLWin32(url) { | |||
| 1352 | 1352 | ||
| 1353 | 1353 | function getPathFromURLPosix(url) { | |
| 1354 | 1354 | if (url.hostname !== '') { | |
| 1355 | - return new errors.TypeError('ERR_INVALID_FILE_URL_HOST', | ||
| 1356 | - `must be "localhost" or empty on ${platform}`); | ||
| 1355 | + return new errors.TypeError('ERR_INVALID_FILE_URL_HOST', platform); | ||
| 1357 | 1356 | } | |
| 1358 | 1357 | var pathname = url.pathname; | |
| 1359 | 1358 | for (var n = 0; n < pathname.length; n++) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -60,11 +60,8 @@ const server = net.createServer(function(s) { | |||
| 60 | 60 | send(function(err) { | |
| 61 | 61 | // Ignore errors when sending the second handle because the worker | |
| 62 | 62 | // may already have exited. | |
| 63 | - if (err) { | ||
| 64 | - if ((err.message !== 'channel closed') && | ||
| 65 | - (err.code !== 'ECONNREFUSED')) { | ||
| 66 | - throw err; | ||
| 67 | - } | ||
| 63 | + if (err && err.message !== 'Channel closed') { | ||
| 64 | + throw err; | ||
| 68 | 65 | } | |
| 69 | 66 | }); | |
| 70 | 67 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,9 +10,11 @@ child.on('close', common.mustCall((code, signal) => { | |||
| 10 | 10 | assert.strictEqual(code, 0); | |
| 11 | 11 | assert.strictEqual(signal, null); | |
| 12 | 12 | ||
| 13 | - function testError(err) { | ||
| 14 | - assert.strictEqual(err.message, 'channel closed'); | ||
| 15 | - } | ||
| 13 | + const testError = common.expectsError({ | ||
| 14 | + type: Error, | ||
| 15 | + message: 'Channel closed', | ||
| 16 | + code: 'ERR_IPC_CHANNEL_CLOSED' | ||
| 17 | + }); | ||
| 16 | 18 | ||
| 17 | 19 | child.on('error', common.mustCall(testError)); | |
| 18 | 20 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -43,6 +43,6 @@ process.on('exit', function() { | |||
| 43 | 43 | common.expectsError({ | |
| 44 | 44 | code: 'ERR_INVALID_CALLBACK', | |
| 45 | 45 | type: TypeError, | |
| 46 | - message: 'callback must be a function' | ||
| 46 | + message: 'Callback must be a function' | ||
| 47 | 47 | })); | |
| 48 | 48 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,15 +1,14 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | const common = require('../common'); | |
| 3 | - const assert = require('assert'); | ||
| 4 | 3 | const { Transform } = require('stream'); | |
| 5 | 4 | const stream = new Transform({ | |
| 6 | 5 | transform(chunk, enc, cb) { cb(); cb(); } | |
| 7 | 6 | }); | |
| 8 | 7 | ||
| 9 | - stream.on('error', common.mustCall((err) => { | ||
| 10 | - assert.strictEqual(err.toString(), | ||
| 11 | - 'Error [ERR_TRANSFORM_MULTIPLE_CALLBACK]: ' + | ||
| 12 | - 'Callback called multiple times'); | ||
| 8 | + stream.on('error', common.expectsError({ | ||
| 9 | + type: Error, | ||
| 10 | + message: 'Callback called multiple times', | ||
| 11 | + code: 'ERR_MULTIPLE_CALLBACK' | ||
| 13 | 12 | })); | |
| 14 | 13 | ||
| 15 | 14 | stream.write('foo'); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments