Skip to content

Commit

Permalink
fixup! update to ERR_INVALID_STATE
Browse files Browse the repository at this point in the history
  • Loading branch information
debadree25 committed Jun 8, 2023
1 parent 845e322 commit 48a8af4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/internal/webstreams/readablestream.js
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,8 @@ function readableStreamFromIterable(iterable) {
const nextPromise = PromiseResolve(nextResult);
return PromisePrototypeThen(nextPromise, (iterResult) => {
if (typeof iterResult !== 'object' || iterResult === null) {
throw new ERR_INVALID_ARG_VALUE.TypeError('iterResult', iterResult);
throw new ERR_INVALID_STATE.TypeError(
'The promise returned by the iterator.next() method must fulfill with an object');
}
const done = Boolean(iterResult.done);
if (done) {
Expand Down Expand Up @@ -1303,7 +1304,8 @@ function readableStreamFromIterable(iterable) {
const returnPromise = PromiseResolve(returnResult);
return PromisePrototypeThen(returnPromise, (iterResult) => {
if (typeof iterResult !== 'object' || iterResult === null) {
throw new ERR_INVALID_ARG_VALUE.TypeError('iterResult', iterResult);
throw new ERR_INVALID_STATE.TypeError(
'The promise returned by the iterator.return() method must fulfill with an object');
}
return undefined;
});
Expand Down
5 changes: 3 additions & 2 deletions lib/internal/webstreams/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const {
codes: {
ERR_INVALID_ARG_VALUE,
ERR_OPERATION_FAILED,
ERR_INVALID_STATE,
},
} = require('internal/errors');

Expand Down Expand Up @@ -248,7 +249,7 @@ function getIterator(obj, kind = 'sync', method) {

const iterator = FunctionPrototypeCall(method, obj);
if (typeof iterator !== 'object' || iterator === null) {
throw new ERR_INVALID_ARG_VALUE.TypeError('iterator', iterator);
throw new ERR_INVALID_STATE.TypeError('The iterator method must return an object');
}
const nextMethod = iterator.next;
return { iterator, nextMethod, done: false };
Expand All @@ -262,7 +263,7 @@ function iteratorNext(iteratorRecord, value) {
result = FunctionPrototypeCall(iteratorRecord.nextMethod, iteratorRecord.iterator, [value]);
}
if (typeof result !== 'object' || result === null) {
throw new ERR_INVALID_ARG_VALUE.TypeError('iterator.next', result);
throw new ERR_INVALID_STATE.TypeError('The iterator.next() method must return an object');
}
return result;
}
Expand Down

0 comments on commit 48a8af4

Please sign in to comment.