GPUUncapturedErrorEvent

Khả dụng hạn chế

This feature is not Baseline because it does not work in some of the most widely-used 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 GPUUncapturedErrorEvent của WebGPU API là loại đối tượng sự kiện cho sự kiện GPUDevice uncapturederror, được sử dụng để đo lường và báo cáo các lỗi không mong đợi.

Các trường hợp lỗi đã biết nên được xử lý bằng pushErrorScope()popErrorScope().

Event GPUUncapturedErrorEvent

Hàm khởi tạo

GPUUncapturedErrorEvent()

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

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

Kế thừa các thuộc tính từ thực thể cha, Event.

error Read only

Một phiên bản đối tượng GPUError cung cấp quyền truy cập vào thông tin chi tiết của lỗi.

Ví dụ

Bạn có thể sử dụng thứ như sau như một cơ chế toàn cục để phát hiện các lỗi không được xử lý bởi error scopes và ghi lại chúng.

js
// …

device.addEventListener("uncapturederror", (event) => {
  // Re-surface the error
  console.error("A WebGPU error was not captured:", event.error.message);
  reportErrorToServer({
    type: event.error.constructor.name,
    message: event.error.message,
  });
});

// …

Thông số kỹ thuật

Thông số kỹ thuật
WebGPU
# gpuuncapturederrorevent

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

Xem thêm