W3cubDocs

/Web APIs

GPUDevice: pushErrorScope() method

Limited availability

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.

The pushErrorScope() method of the GPUDevice interface pushes a new GPU error scope onto the device's error scope stack, allowing you to capture errors of a particular type.

Once you are done capturing errors, you can end capture by invoking GPUDevice.popErrorScope(). This pops the scope from the stack and returns a Promise that resolves to an object describing the first error captured in the scope, or null if no errors were captured.

Syntax

pushErrorScope(filter)

Parameters

filter

An enumerated value that specifies what type of error will be caught in this particular error scope. Possible values are:

"internal"

The error scope will catch a GPUInternalError.

"out-of-memory"

The error scope will catch a GPUOutOfMemoryError.

"validation"

The error scope will catch a GPUValidationError.

Return value

None (Undefined).

Examples

The following example uses an error scope to capture a suspected validation error, logging it to the console.

device.pushErrorScope("validation");

let sampler = device.createSampler({
  maxAnisotropy: 0, // Invalid, maxAnisotropy must be at least 1.
});

device.popErrorScope().then((error) => {
  if (error) {
    sampler = null;
    console.error(`An error occurred while creating sampler: ${error.message}`);
  }
});

See WebGPU Error Handling best practices for a lot more examples and information.

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
pushErrorScope
113Currently supported on ChromeOS, macOS, and Windows only.
113Currently supported on ChromeOS, macOS, and Windows only.
141Currently supported on Windows only, in all contexts except for service workers.
99Currently supported on ChromeOS, macOS, and Windows only.
26 121 No 81 26 25.0 121 26

See also

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/pushErrorScope