TransformStreamDefaultController: error() メソッド
Invalid slug for templ/sidebar: Streams API
error()
は TransformStreamDefaultController
インターフェイスのメソッドで、両側のストリームをエラーにします。これ以上何か操作をすると、指定されたエラーメッセージとともに失敗するようになり、キュー内のチャンクは破棄されます。
構文
js
error(reason)
引数
reason
-
それ以降のストリームの操作において返されるエラーメッセージを格納した文字列。
返値
なし (undefined
)。
例
この例では、チャンクが変換できなかったときに error()
メソッドを使用しています。
js
const transformContent = {
start() {
/* … */
},
async transform(chunk, controller) {
try {
chunk = await applyMyTransformation(chunk);
} catch (err) {
controller.error(`Unable to transform chunk: ${err}`);
}
// …
},
// …
};
仕様書
Specification |
---|
Streams # ts-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.