Skip to content

Commit ed01bfe

Browse files
jasnelladdaleax
authored andcommitted
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. Original-PR-URL: #13604 Original-Reviewed-By: Luigi Pinca <[email protected]> Original-Reviewed-By: Timothy Gu <[email protected]> Original-Reviewed-By: Gibson Fahnestock <[email protected]> Original-Reviewed-By: Anna Henningsen <[email protected]> Original-Reviewed-By: Refael Ackermann <[email protected]> Original-Reviewed-By: Colin Ihrig <[email protected]> Original-Reviewed-By: Benjamin Gruenbaum <[email protected]> PR-URL: #13750 Reviewed-By: Anna Henningsen <[email protected]>
1 parent 66349af commit ed01bfe

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

‎doc/api/errors.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,12 @@ The `'ERR_ARG_NOT_ITERABLE'` error code is used generically to identify that an
570570
iterable argument (i.e. a value that works with `for...of` loops) is required,
571571
but not provided to a Node.js API.
572572

573+
<aid="ERR_FALSY_VALUE_REJECTION"></a>
574+
### ERR_FALSY_VALUE_REJECTION
575+
576+
The `ERR_FALSY_VALUE_REJECTION` error code is used by the `util.callbackify()`
577+
API when a callbackified `Promise` is rejected with a falsy value (e.g. `null`).
578+
573579
<aid="ERR_INVALID_ARG_TYPE"></a>
574580
### ERR_INVALID_ARG_TYPE
575581

‎lib/internal/errors.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ module.exports = exports ={
112112
// Note: Please try to keep these in alphabetical order
113113
E('ERR_ARG_NOT_ITERABLE','%s must be iterable');
114114
E('ERR_ASSERTION',(msg)=>msg);
115+
E('ERR_FALSY_VALUE_REJECTION','Promise was rejected with falsy value');
115116
E('ERR_INVALID_ARG_TYPE',invalidArgType);
116117
E('ERR_INVALID_CALLBACK','callback must be a function');
117118
E('ERR_INVALID_FD',(fd)=>`"fd" must be a positive integer: ${fd}`);
@@ -149,7 +150,6 @@ E('ERR_SOCKET_BAD_TYPE',
149150
E('ERR_SOCKET_CANNOT_SEND','Unable to send data');
150151
E('ERR_SOCKET_BAD_PORT','Port should be > 0 and < 65536');
151152
E('ERR_SOCKET_DGRAM_NOT_RUNNING','Not running');
152-
E('FALSY_VALUE_REJECTION','Promise was rejected with falsy value');
153153
// Add new errors from here...
154154

155155
functioninvalidArgType(name,expected,actual){

‎lib/util.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ function callbackifyOnRejected(reason, cb){
10631063
// occurred", we error-wrap so the callback consumer can distinguish between
10641064
// "the promise rejected with null" or "the promise fulfilled with undefined".
10651065
if(!reason){
1066-
constnewReason=newerrors.Error('FALSY_VALUE_REJECTION');
1066+
constnewReason=newerrors.Error('ERR_FALSY_VALUE_REJECTION');
10671067
newReason.reason=reason;
10681068
reason=newReason;
10691069
Error.captureStackTrace(reason,callbackifyOnRejected);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const values = [
7979
if(errinstanceofError){
8080
if('reason'inerr){
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(errinstanceofError){
101101
if('reason'inerr){
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(errinstanceofError){
126126
if('reason'inerr){
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)