TransformStreamDefaultController: error() method
Note: This feature is available in Web Workers.
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
js
error(reason)
Parameters
reason
-
A string containing the error message to be returned on any further interaction with the stream.
Return value
None (undefined
).
Examples
In this example the error()
method is used when a chunk could not be transformed.
js
const transformContent = {
start() {
/* … */
},
async transform(chunk, controller) {
try {
chunk = await applyMyTransformation(chunk);
} catch (err) {
controller.error(`Unable to transform chunk: ${err}`);
}
// …
},
// …
};
Specifications
Specification |
---|
Streams Standard # ts-default-controller-error |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
error |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.