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()).
Hàm khởi tạo
WebTransportError()-
Tạo phiên bản đối tượng
WebTransportErrormới.
Thuộc tính phiên bản
Kế thừa các thuộc tính từ cha, DOMException.
sourceRead only-
Trả về giá trị liệt kê cho biết nguồn gốc của lỗi, có thể là
streamhoặcsession. streamErrorCodeRead 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
nullnếu không có.
Ví dụ
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
| Specification |
|---|
| WebTransport> # webtransporterror> |