GPUDevice: pushErrorScope() method - Web APIs | MDN
Syntax
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.
js
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
| Specification |
|---|
| WebGPU # dom-gpudevice-pusherrorscope |
Browser compatibility
See also
- The WebGPU API