diff options
author | Kunal Mohan <kunalmohan99@gmail.com> | 2020-08-02 12:45:22 +0530 |
---|---|---|
committer | Kunal Mohan <kunalmohan99@gmail.com> | 2020-08-02 12:45:22 +0530 |
commit | cd8d9162e66b9cdf03918fc3c24d855e6938edb7 (patch) | |
tree | c74ad16bd2128ef5adf68d85ac7bf7a30ffa0cfe /components/script/dom/gpuadapter.rs | |
parent | 8cb5fad8286d87f2e852d870581d4f867afaf435 (diff) | |
download | servo-cd8d9162e66b9cdf03918fc3c24d855e6938edb7.tar.gz servo-cd8d9162e66b9cdf03918fc3c24d855e6938edb7.zip |
Error handling for promise returning operations
Diffstat (limited to 'components/script/dom/gpuadapter.rs')
-rw-r--r-- | components/script/dom/gpuadapter.rs | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/components/script/dom/gpuadapter.rs b/components/script/dom/gpuadapter.rs index 9392f1414fa..ca4eaacd2ae 100644 --- a/components/script/dom/gpuadapter.rs +++ b/components/script/dom/gpuadapter.rs @@ -20,7 +20,7 @@ use dom_struct::dom_struct; use js::jsapi::{Heap, JSObject}; use std::ptr::NonNull; use std::rc::Rc; -use webgpu::{wgt, WebGPU, WebGPUAdapter, WebGPURequest, WebGPUResponse}; +use webgpu::{wgt, WebGPU, WebGPUAdapter, WebGPURequest, WebGPUResponse, WebGPUResponseResult}; #[dom_struct] pub struct GPUAdapter { @@ -114,14 +114,14 @@ impl GPUAdapterMethods for GPUAdapter { } impl AsyncWGPUListener for GPUAdapter { - fn handle_response(&self, response: WebGPUResponse, promise: &Rc<Promise>) { + fn handle_response(&self, response: WebGPUResponseResult, promise: &Rc<Promise>) { match response { - WebGPUResponse::RequestDevice { + Ok(WebGPUResponse::RequestDevice { device_id, queue_id, _descriptor, label, - } => { + }) => { let device = GPUDevice::new( &self.global(), self.channel.clone(), @@ -135,7 +135,14 @@ impl AsyncWGPUListener for GPUAdapter { self.global().add_gpu_device(&device); promise.resolve_native(&device); }, - _ => promise.reject_error(Error::Operation), + Err(e) => { + warn!("Could not get GPUDevice({:?})", e); + promise.reject_error(Error::Operation); + }, + _ => { + warn!("GPUAdapter received wrong WebGPUResponse"); + promise.reject_error(Error::Operation); + }, } } } |