From 2ca454b402d48c1808f8233c5adedc11b714c63c Mon Sep 17 00:00:00 2001 From: Aaron O'Mullan Date: Sun, 15 Aug 2021 13:29:19 +0200 Subject: refactor(ops): return BadResource errors in ResourceTable calls (#11710) * refactor(ops): return BadResource errors in ResourceTable calls Instead of relying on callers to map Options to Results via `.ok_or_else(bad_resource_id)` at over 176 different call sites ... --- ext/webgpu/lib.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'ext/webgpu/lib.rs') diff --git a/ext/webgpu/lib.rs b/ext/webgpu/lib.rs index 9a39ea4a2..aa9de2110 100644 --- a/ext/webgpu/lib.rs +++ b/ext/webgpu/lib.rs @@ -1,7 +1,7 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. +use deno_core::error::not_supported; use deno_core::error::AnyError; -use deno_core::error::{bad_resource_id, not_supported}; use deno_core::include_js_files; use deno_core::op_async; use deno_core::op_sync; @@ -398,8 +398,7 @@ pub async fn op_webgpu_request_device( let mut state = state.borrow_mut(); let adapter_resource = state .resource_table - .get::(args.adapter_rid) - .ok_or_else(bad_resource_id)?; + .get::(args.adapter_rid)?; let adapter = adapter_resource.0; let instance = state.borrow::(); @@ -533,10 +532,8 @@ pub fn op_webgpu_create_query_set( args: CreateQuerySetArgs, _: (), ) -> Result { - let device_resource = state - .resource_table - .get::(args.device_rid) - .ok_or_else(bad_resource_id)?; + let device_resource = + state.resource_table.get::(args.device_rid)?; let device = device_resource.0; let instance = &state.borrow::(); -- cgit v1.2.3