Standard built-ins
AsyncGenerator.prototype.throw()
Queues an exception at the suspension point and returns a promise, which rejects if the error is unhandled.
Formal Syntax & Structure
javascript syntaxjavascript
asyncGenerator.throw([value])Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| value | any | Optional resumption, completion or error value. |
Return Value
Promise<IteratorResult>
Promise for the iteration result.
Working Example
Example Snippetjavascript
async function* g(){try{yield 1;}catch(e){yield e.message;}}(async()=>{const i=g();await i.next();console.log((await i.throw(new Error("x"))).value);})();