Skip to content

Commit 873e2f2

Browse files
committedJun 13, 2017
errors: add missing ERR_ prefix on util.callbackify error
The `FALSY_VALUE_REJECTION` error code added by #12712 did not have the `ERR_` prefix, nor was it added to the errors.md documentation. Add the prefix in for consistency. PR-URL: #13604 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
1 parent f308b4d commit 873e2f2

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed
 

‎doc/api/errors.md

+6
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,12 @@ The `ERR_CONSOLE_WRITABLE_STREAM` error code is thrown when `Console` is
576576
instantiated without `stdout` stream or when `stdout` or `stderr` streams
577577
are not writable.
578578

579+
<a id="ERR_FALSY_VALUE_REJECTION"></a>
580+
### ERR_FALSY_VALUE_REJECTION
581+
582+
The `ERR_FALSY_VALUE_REJECTION` error code is used by the `util.callbackify()`
583+
API when a callbackified `Promise` is rejected with a falsy value (e.g. `null`).
584+
579585
<a id="ERR_INDEX_OUT_OF_RANGE"></a>
580586
### ERR_INDEX_OUT_OF_RANGE
581587

‎lib/internal/errors.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ E('ERR_ASSERTION', (msg) => msg);
115115
E('ERR_CONSOLE_WRITABLE_STREAM',
116116
(name) => `Console expects a writable stream instance for ${name}`);
117117
E('ERR_CPU_USAGE', (errMsg) => `Unable to obtain cpu usage ${errMsg}`);
118+
E('ERR_FALSY_VALUE_REJECTION', 'Promise was rejected with falsy value');
118119
E('ERR_HTTP_HEADERS_SENT',
119120
'Cannot render headers after they are sent to the client');
120121
E('ERR_HTTP_INVALID_CHAR', 'Invalid character in statusMessage.');
@@ -166,7 +167,6 @@ E('ERR_SOCKET_BAD_PORT', 'Port should be > 0 and < 65536');
166167
E('ERR_SOCKET_DGRAM_NOT_RUNNING', 'Not running');
167168
E('ERR_V8BREAKITERATOR', 'full ICU data not installed. ' +
168169
'See https://github.com/nodejs/node/wiki/Intl');
169-
E('FALSY_VALUE_REJECTION', 'Promise was rejected with falsy value');
170170
// Add new errors from here...
171171

172172
function invalidArgType(name, expected, actual) {

‎lib/util.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ function callbackifyOnRejected(reason, cb) {
10541054
// occurred", we error-wrap so the callback consumer can distinguish between
10551055
// "the promise rejected with null" or "the promise fulfilled with undefined".
10561056
if (!reason) {
1057-
const newReason = new errors.Error('FALSY_VALUE_REJECTION');
1057+
const newReason = new errors.Error('ERR_FALSY_VALUE_REJECTION');
10581058
newReason.reason = reason;
10591059
reason = newReason;
10601060
Error.captureStackTrace(reason, callbackifyOnRejected);

‎test/parallel/test-util-callbackify.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const values = [
7979
if (err instanceof Error) {
8080
if ('reason' in err) {
8181
assert(!value);
82-
assert.strictEqual(err.code, 'FALSY_VALUE_REJECTION');
82+
assert.strictEqual(err.code, 'ERR_FALSY_VALUE_REJECTION');
8383
assert.strictEqual(err.reason, value);
8484
} else {
8585
assert.strictEqual(String(value).endsWith(err.message), true);
@@ -100,7 +100,7 @@ const values = [
100100
if (err instanceof Error) {
101101
if ('reason' in err) {
102102
assert(!value);
103-
assert.strictEqual(err.code, 'FALSY_VALUE_REJECTION');
103+
assert.strictEqual(err.code, 'ERR_FALSY_VALUE_REJECTION');
104104
assert.strictEqual(err.reason, value);
105105
} else {
106106
assert.strictEqual(String(value).endsWith(err.message), true);
@@ -125,7 +125,7 @@ const values = [
125125
if (err instanceof Error) {
126126
if ('reason' in err) {
127127
assert(!value);
128-
assert.strictEqual(err.code, 'FALSY_VALUE_REJECTION');
128+
assert.strictEqual(err.code, 'ERR_FALSY_VALUE_REJECTION');
129129
assert.strictEqual(err.reason, value);
130130
} else {
131131
assert.strictEqual(String(value).endsWith(err.message), true);

0 commit comments

Comments
 (0)