@@ -4,7 +4,7 @@ use crate::database_logger::{LogLevel, Record};
44use crate :: error:: NodesError ;
55use crate :: host:: instance_env:: InstanceEnv ;
66use crate :: host:: v8:: de:: { deserialize_js, scratch_buf} ;
7- use crate :: host:: v8:: error:: { ExcResult , ExceptionThrown , TypeError } ;
7+ use crate :: host:: v8:: error:: { ErrorOrException , ExcResult , ExceptionThrown } ;
88use crate :: host:: v8:: from_value:: cast;
99use crate :: host:: v8:: ser:: serialize_to_js;
1010use crate :: host:: v8:: string:: { str_from_ident, StringConst } ;
@@ -16,6 +16,7 @@ use crate::host::wasm_common::instrumentation::span;
1616use crate :: host:: wasm_common:: module_host_actor:: { ReducerOp , ReducerResult } ;
1717use crate :: host:: wasm_common:: { err_to_errno_and_log, RowIterIdx , TimingSpan , TimingSpanIdx } ;
1818use crate :: host:: AbiCall ;
19+ use anyhow:: Context ;
1920use spacetimedb_lib:: { bsatn, ConnectionId , Identity , RawModuleDef } ;
2021use spacetimedb_primitives:: { errno, ColId , IndexId , ReducerId , TableId } ;
2122use spacetimedb_sats:: Serialize ;
@@ -363,7 +364,10 @@ pub(super) fn call_call_reducer(
363364}
364365
365366/// Calls the registered `__describe_module__` function hook.
366- pub ( super ) fn call_describe_module ( scope : & mut PinScope < ' _ , ' _ > , fun : Local < ' _ , Function > ) -> ExcResult < RawModuleDef > {
367+ pub ( super ) fn call_describe_module (
368+ scope : & mut PinScope < ' _ , ' _ > ,
369+ fun : Local < ' _ , Function > ,
370+ ) -> Result < RawModuleDef , ErrorOrException < ExceptionThrown > > {
367371 // Call the function.
368372 let raw_mod_js = call_free_fun ( scope, fun, & [ ] ) ?;
369373
@@ -377,8 +381,7 @@ pub(super) fn call_describe_module(scope: &mut PinScope<'_, '_>, fun: Local<'_,
377381 . map_err ( |e| e. throw ( scope) ) ?;
378382
379383 let bytes = raw_mod. get_contents ( & mut [ ] ) ;
380- let module =
381- bsatn:: from_slice :: < RawModuleDef > ( bytes) . map_err ( |_e| TypeError ( "invalid bsatn module def" ) . throw ( scope) ) ?;
384+ let module = bsatn:: from_slice :: < RawModuleDef > ( bytes) . context ( "invalid bsatn module def" ) ?;
382385 Ok ( module)
383386}
384387
0 commit comments