WritableStreamDefaultController: error() メソッド
メモ: この機能はウェブワーカー内で利用可能です。
WritableStreamDefaultController
インターフェイスの error()
メソッドにより、関連するストリームとの今後のやり取りがエラーになります。
通常、基になるシンクのメソッドの 1 つから拒否されたプロミスを返すだけで十分なため、このメソッドはほとんど使用されません。 ただし、基になるシンクとのやり取りの通常のライフサイクル外のイベントに応答して、ストリームを突然シャットダウンする場合に役立ちます。
構文
js
error(message)
引数
message
-
文字列で、将来の操作を失敗するようにしたいエラーを表します。
返値
なし (undefined
)。
例外
TypeError
-
エラーにしようとしているストリームは
WritableStream
ではありません。
例
js
const writableStream = new WritableStream({
start(controller) {
// コントローラーで何かをする
// 必要に応じてストリームをエラーにする
controller.error("My error is broken");
},
write(chunk, controller) {
// ...
},
close(controller) {
// ...
},
abort(err) {
// ...
},
});
仕様書
Specification |
---|
Streams # ref-for-ws-default-controller-error① |
ブラウザーの互換性
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.