Web APIs
ReadableStreamDefaultController.prototype.error()
Errors the readable stream; pending and future read operations reject with the stored reason.
Formal Syntax & Structure
javascript syntaxjavascript
controller.error(reason)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| reason | any | Stored stream error. |
Return Value
undefined
Errors the readable stream; pending and future read operations reject with the stored reason.
Working Example
Example Snippetjavascript
(async () => {const s=new ReadableStream({start(c){c.error(new Error("bad data"));}});const r=s.getReader();try{await r.read();}catch(e){console.log(e.message);}finally{r.releaseLock();}})()