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

瀏覽器相容性

另見