WebTransportError

Baseline 2026
Newly available

Since March 2026, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Note: This feature is available in Web Workers.

Giao diện WebTransportError của WebTransport API đại diện cho lỗi liên quan đến API, có thể phát sinh từ lỗi máy chủ, sự cố kết nối mạng, hoặc hoạt động hủy bỏ do khách hàng khởi tạo (ví dụ: phát sinh từ lệnh gọi WritableStream.abort()).

DOMException WebTransportError

Hàm khởi tạo

WebTransportError()

Tạo phiên bản đối tượng WebTransportError mới.

Thuộc tính phiên bản

Kế thừa các thuộc tính từ cha, DOMException.

source Read only

Trả về giá trị liệt kê cho biết nguồn gốc của lỗi, có thể là stream hoặc session.

streamErrorCode Read only

Trả về một số trong khoảng 0-255 cho biết mã lỗi giao thức ứng dụng cho lỗi này, hoặc null nếu không có.

Ví dụ

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);
  }
}

Thông số kỹ thuật

Thông số kỹ thuật
WebTransport
# webtransporterror

Tương thích trình duyệt

Xem thêm