summaryrefslogtreecommitdiff
path: root/core/bindings.rs
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@gmail.com>2021-08-15 13:29:19 +0200
committerGitHub <noreply@github.com>2021-08-15 13:29:19 +0200
commit2ca454b402d48c1808f8233c5adedc11b714c63c (patch)
tree592f9e877e9b0ae92be80383ab723cc290e4b01e /core/bindings.rs
parent18ff6bb053d600c277613628a256fe5fdd4dda67 (diff)
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 ...
Diffstat (limited to 'core/bindings.rs')
-rw-r--r--core/bindings.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/core/bindings.rs b/core/bindings.rs
index 935397480..9bfe767c3 100644
--- a/core/bindings.rs
+++ b/core/bindings.rs
@@ -611,13 +611,14 @@ fn wasm_streaming_feed(
let state = state_rc.borrow();
// If message_type is not Bytes, we'll be consuming the WasmStreaming
// instance, so let's also remove it from the resource table.
- let wasm_streaming: Option<Rc<WasmStreamingResource>> = match message_type {
- MessageType::Bytes => state.op_state.borrow().resource_table.get(rid),
- _ => state.op_state.borrow_mut().resource_table.take(rid),
- };
+ let wasm_streaming: Result<Rc<WasmStreamingResource>, AnyError> =
+ match message_type {
+ MessageType::Bytes => state.op_state.borrow().resource_table.get(rid),
+ _ => state.op_state.borrow_mut().resource_table.take(rid),
+ };
match wasm_streaming {
- Some(wasm_streaming) => wasm_streaming,
- None => return throw_type_error(scope, "Invalid resource ID."),
+ Ok(wasm_streaming) => wasm_streaming,
+ Err(e) => return throw_type_error(scope, e.to_string()),
}
};