Back to Content

GPUUncapturedErrorEvent

files/en-us/web/api/gpuuncapturederrorevent/index.md

latest1.6 KB
Original Source

{{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 GPUUncapturedErrorEvent object 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.

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

// …

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also