TransformStreamDefaultController.error()

The error() method of the TransformStreamDefaultController interface errors both sides of the stream. Any further interactions with it will fail with the given error message, and any chunks in the queue will be discarded.

Syntax

error(reason)

Parameters

reason

A string containing the error message to be returned on any further interaction with the stream.

Examples

In this example the error() method is used when a chunk contains a symbol.

case 'symbol':
  controller.error("Cannot send a symbol as a chunk part")
  break

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
error
67
79
No
No
54
14.1
67
67
No
48
14.5
9.0

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/TransformStreamDefaultController/error