Web APIs

ReadableStreamDefaultController.prototype.error()

Try the free JavaScript compiler

Errors the readable stream; pending and future read operations reject with the stored reason.

Formal Syntax & Structure

javascript syntaxjavascript
controller.error(reason)

Parameters & Attributes

NameTypeDescription
reasonanyStored 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();}})()
JavaScript Reference