WebTransportError:streamErrorCode 属性

可用性有限

此特性不是基线特性,因为它在一些最广泛使用的浏览器中不起作用。

安全上下文: 此功能仅在安全上下文(HTTPS)中可用,且支持此功能的浏览器数量有限。

注意:此功能在 Web Workers 中可用。

streamErrorCodeWebTransportError 接口的一个只读属性,它返回一个 0-255 范围内的数字,表示此错误的应用协议错误代码;如果不可用,则返回 null

一个数字,或 null

示例

js
const url = "not-a-url";

async function initTransport(url) {
  try {
    // Initialize transport connection
    const transport = new WebTransport(url);

    // The connection can be used once ready fulfills
    await transport.ready;

    // …
  } catch (error) {
    const msg = `Transport initialization failed.
                 Reason: ${error.message}.
                 Source: ${error.source}.
                 Error code: ${error.streamErrorCode}.`;
    console.log(msg);
  }
}

规范

规范
WebTransport
# dom-webtransporterror-streamerrorcode

浏览器兼容性

另见