WebTransportError
注意:此功能在 Web Workers 中可用。
WebTransportError 介面是 WebTransport API 的一部分,用於表示與該 API 相關的錯誤,這些錯誤可能源於伺服器錯誤、網路連線問題或客戶端發起的中止操作(例如,由 WritableStream.abort() 呼叫引起)。
建構函式
WebTransportError()-
建立一個新的
WebTransportError物件例項。
例項屬性
繼承其父級 DOMException 的屬性。
source只讀-
返回一個列舉值,指示錯誤的來源—可以是
stream或session。 streamErrorCode只讀-
返回一個 0-255 範圍內的數字,指示此錯誤的應用程式協議錯誤程式碼,如果不可用則返回
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 # webtransporterror |
瀏覽器相容性
載入中…