Skip to content

Commit 0a8258b

Browse files
maclover7jasnell
authored andcommitted
errors: remove duplicate error definition
Also fixes error being (now!) properly thrown by alphabetize-errors. also properly enable lint rule Was not using proper magic comment syntax before! -URL: #15307 Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent a14b252 commit 0a8258b

File tree

2 files changed

+36
-13
lines changed

2 files changed

+36
-13
lines changed

doc/api/errors.md

100644100755
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,22 @@ Used when an attempt is made to launch a Node.js process with an unknown
998998
by errors in user code, although it is not impossible. Occurrences of this error
999999
are most likely an indication of a bug within Node.js itself.
10001000

1001+
<a id="ERR_V8BREAKITERATOR"></a>
1002+
### ERR_V8BREAKITERATOR
1003+
1004+
Used when the V8 BreakIterator API is used but the full ICU data set is not
1005+
installed.
1006+
1007+
<a id="ERR_VALID_PERFORMANCE_ENTRY_TYPE"></a>
1008+
### ERR_VALID_PERFORMANCE_ENTRY_TYPE
1009+
1010+
Used by the Performance Timing API (`perf_hooks`) when no valid performance
1011+
entry types were found.
1012+
1013+
<a id="ERR_VALUE_OUT_OF_RANGE"></a>
1014+
### ERR_VALUE_OUT_OF_RANGE
1015+
1016+
Used when a given value is out of the accepted range.
10011017

10021018
[`ERR_INVALID_ARG_TYPE`]: #ERR_INVALID_ARG_TYPE
10031019
[`subprocess.kill()`]: child_process.html#child_process_subprocess_kill_signal

lib/internal/errors.js

100644100755
Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-enable alphabetize-errors */
1+
/* eslint alphabetize-errors: "error" */
22

33
'use strict';
44

@@ -127,11 +127,11 @@ E('ERR_ENCODING_NOT_SUPPORTED',
127127
E('ERR_FALSY_VALUE_REJECTION', 'Promise was rejected with falsy value');
128128
E('ERR_HTTP_HEADERS_SENT',
129129
'Cannot render headers after they are sent to the client');
130-
E('ERR_HTTP_TRAILER_INVALID',
131-
'Trailers are invalid with this transfer encoding');
132130
E('ERR_HTTP_INVALID_CHAR', 'Invalid character in statusMessage.');
133131
E('ERR_HTTP_INVALID_STATUS_CODE',
134132
(originalStatusCode) => `Invalid status code: ${originalStatusCode}`);
133+
E('ERR_HTTP_TRAILER_INVALID',
134+
'Trailers are invalid with this transfer encoding');
135135
E('ERR_HTTP2_CONNECT_AUTHORITY',
136136
':authority header is required for CONNECT requests');
137137
E('ERR_HTTP2_CONNECT_PATH',
@@ -150,10 +150,10 @@ E('ERR_HTTP2_HEADER_REQUIRED',
150150
(name) => `The ${name} header is required`);
151151
E('ERR_HTTP2_HEADER_SINGLE_VALUE',
152152
(name) => `Header field "${name}" must have only a single value`);
153-
E('ERR_HTTP2_HEADERS_OBJECT', 'Headers must be an object');
154-
E('ERR_HTTP2_HEADERS_SENT', 'Response has already been initiated.');
155153
E('ERR_HTTP2_HEADERS_AFTER_RESPOND',
156154
'Cannot specify additional headers after response initiated');
155+
E('ERR_HTTP2_HEADERS_OBJECT', 'Headers must be an object');
156+
E('ERR_HTTP2_HEADERS_SENT', 'Response has already been initiated.');
157157
E('ERR_HTTP2_INFO_HEADERS_AFTER_RESPOND',
158158
'Cannot send informational headers after the HTTP message has been sent');
159159
E('ERR_HTTP2_INFO_STATUS_NOT_ALLOWED',
@@ -168,24 +168,24 @@ E('ERR_HTTP2_INVALID_PACKED_SETTINGS_LENGTH',
168168
E('ERR_HTTP2_INVALID_PSEUDOHEADER',
169169
(name) => `"${name}" is an invalid pseudoheader or is used incorrectly`);
170170
E('ERR_HTTP2_INVALID_SESSION', 'The session has been destroyed');
171-
E('ERR_HTTP2_INVALID_STREAM', 'The stream has been destroyed');
172171
E('ERR_HTTP2_INVALID_SETTING_VALUE',
173172
(name, value) => `Invalid value for setting "${name}": ${value}`);
173+
E('ERR_HTTP2_INVALID_STREAM', 'The stream has been destroyed');
174174
E('ERR_HTTP2_MAX_PENDING_SETTINGS_ACK',
175175
(max) => `Maximum number of pending settings acknowledgements (${max})`);
176-
E('ERR_HTTP2_PAYLOAD_FORBIDDEN',
177-
(code) => `Responses with ${code} status must not have a payload`);
178176
E('ERR_HTTP2_OUT_OF_STREAMS',
179177
'No stream ID is available because maximum stream ID has been reached');
178+
E('ERR_HTTP2_PAYLOAD_FORBIDDEN',
179+
(code) => `Responses with ${code} status must not have a payload`);
180180
E('ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED', 'Cannot set HTTP/2 pseudo-headers');
181181
E('ERR_HTTP2_PUSH_DISABLED', 'HTTP/2 client has disabled push streams');
182182
E('ERR_HTTP2_SEND_FILE', 'Only regular files can be sent');
183183
E('ERR_HTTP2_SOCKET_BOUND',
184184
'The socket is already bound to an Http2Session');
185-
E('ERR_HTTP2_STATUS_INVALID',
186-
(code) => `Invalid status code: ${code}`);
187185
E('ERR_HTTP2_STATUS_101',
188186
'HTTP status code 101 (Switching Protocols) is forbidden in HTTP/2');
187+
E('ERR_HTTP2_STATUS_INVALID',
188+
(code) => `Invalid status code: ${code}`);
189189
E('ERR_HTTP2_STREAM_CLOSED', 'The stream is already closed');
190190
E('ERR_HTTP2_STREAM_ERROR',
191191
(code) => `Stream closed with error code ${code}`);
@@ -234,24 +234,31 @@ E('ERR_NAPI_CONS_FUNCTION', 'Constructor must be a function');
234234
E('ERR_NAPI_CONS_PROTOTYPE_OBJECT', 'Constructor.prototype must be an object');
235235
E('ERR_NO_CRYPTO', 'Node.js is not compiled with OpenSSL crypto support');
236236
E('ERR_NO_ICU', '%s is not supported on Node.js compiled without ICU');
237+
E('ERR_OUTOFMEMORY', 'Out of memory');
237238
E('ERR_PARSE_HISTORY_DATA', 'Could not parse history data in %s');
238239
E('ERR_REQUIRE_ESM', 'Must use import to load ES Module: %s');
239240
E('ERR_SOCKET_ALREADY_BOUND', 'Socket is already bound');
241+
E('ERR_SOCKET_BAD_BUFFER_SIZE', 'Buffer size must be a positive integer');
242+
E('ERR_SOCKET_BAD_PORT', 'Port should be > 0 and < 65536');
240243
E('ERR_SOCKET_BAD_TYPE',
241244
'Bad socket type specified. Valid types are: udp4, udp6');
245+
E('ERR_SOCKET_BUFFER_SIZE',
246+
(reason) => `Could not get or set buffer size: ${reason}`);
242247
E('ERR_SOCKET_CANNOT_SEND', 'Unable to send data');
243-
E('ERR_SOCKET_BAD_PORT', 'Port should be > 0 and < 65536');
244248
E('ERR_SOCKET_DGRAM_NOT_RUNNING', 'Not running');
245-
E('ERR_OUTOFMEMORY', 'Out of memory');
246249
E('ERR_STDERR_CLOSE', 'process.stderr cannot be closed');
247250
E('ERR_STDOUT_CLOSE', 'process.stdout cannot be closed');
248251
E('ERR_UNKNOWN_BUILTIN_MODULE', (id) => `No such built-in module: ${id}`);
249252
E('ERR_UNKNOWN_SIGNAL', (signal) => `Unknown signal: ${signal}`);
250253
E('ERR_UNKNOWN_STDIN_TYPE', 'Unknown stdin file type');
251254
E('ERR_UNKNOWN_STREAM_TYPE', 'Unknown stream file type');
255+
E('ERR_V8BREAKITERATOR', 'Full ICU data not installed. ' +
256+
'See https://github.com/nodejs/node/wiki/Intl');
252257
E('ERR_VALID_PERFORMANCE_ENTRY_TYPE',
253258
'At least one valid performance entry type is required');
254-
// Add new errors from here...
259+
E('ERR_VALUE_OUT_OF_RANGE', (start, end, value) => {
260+
return `The value of "${start}" must be ${end}. Received "${value}"`;
261+
});
255262

256263
function invalidArgType(name, expected, actual) {
257264
internalAssert(name, 'name is required');

0 commit comments

Comments
 (0)