Skip to content

Commit

Permalink
Add more error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
MattiasBuelens committed Apr 15, 2021
1 parent fa13e7f commit ca24228
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions reference-implementation/lib/abstract-ops/ecmascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ exports.GetMethod = (V, P) => {
return undefined;
}
if (typeof func !== 'function') {
throw new TypeError();
throw new TypeError(`${P} is not a function`);
}
return func;
};
Expand Down Expand Up @@ -89,7 +89,7 @@ exports.GetIterator = (obj, hint = 'sync', method) => {
}
const iterator = exports.Call(method, obj);
if (!exports.typeIsObject(iterator)) {
throw new TypeError();
throw new TypeError(`The iterator method must return an object`);
}
const nextMethod = iterator.next;
return { iterator, nextMethod, done: false };
Expand All @@ -103,7 +103,7 @@ exports.IteratorNext = (iteratorRecord, value) => {
result = exports.Call(iteratorRecord.nextMethod, iteratorRecord.iterator, [value]);
}
if (!exports.typeIsObject(result)) {
throw new TypeError();
throw new TypeError(`The iterator.next() method must return an object`);
}
return result;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1432,7 +1432,7 @@ function ReadableStreamFromIterable(asyncIterable) {
const nextPromise = promiseResolvedWith(nextResult);
return transformPromiseWith(nextPromise, iterResult => {
if (!typeIsObject(iterResult)) {
throw new TypeError('The iterator.next() method must return an object');
throw new TypeError('The promise returned by the iterator.next() method must fulfill with an object');
}
const done = IteratorComplete(iterResult);
if (done === true) {
Expand Down

0 comments on commit ca24228

Please sign in to comment.