GPUUncapturedErrorEvent
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{APIRef("WebGPU API")}}{{SecureContext_Header}}{{AvailableInWorkers}}
The **GPUUncapturedErrorEvent** interface of the {{domxref("WebGPU API", "WebGPU API", "", "nocode")}} is the event object type for the {{domxref("GPUDevice")}} {{domxref("GPUDevice.uncapturederror_event", "uncapturederror")}} event, used for telemetry and to report unexpected errors.
Known error cases should be handled using {{domxref("GPUDevice.pushErrorScope", "pushErrorScope()")}} and {{domxref("GPUDevice.popErrorScope", "popErrorScope()")}}.
{{InheritanceDiagram}}
Constructor
- {{domxref("GPUUncapturedErrorEvent.GPUUncapturedErrorEvent", "GPUUncapturedErrorEvent()")}}
- : Creates a new
GPUUncapturedErrorEventobject instance.
Instance properties
_Inherits properties from its parent, {{domxref("Event")}}._
- {{domxref("GPUUncapturedErrorEvent.error", "error")}} {{ReadOnlyInline}}
- : A {{domxref("GPUError")}} object instance providing access to the details of the error.
Examples
You could use something like the following as a global mechanism to pick up any errors that aren't handled by error scopes and capture them.
// …
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,
});
});
// …Specifications
{{Specifications}}
Browser compatibility
{{Compat}}
See also
- The WebGPU API
- WebGPU Error Handling best practices