diff --git a/tfhe/src/js_on_wasm_api/js_high_level_api/integers.rs b/tfhe/src/js_on_wasm_api/js_high_level_api/integers.rs index 8c19a4f656..6f00bb5c6d 100644 --- a/tfhe/src/js_on_wasm_api/js_high_level_api/integers.rs +++ b/tfhe/src/js_on_wasm_api/js_high_level_api/integers.rs @@ -980,8 +980,10 @@ macro_rules! define_expander_get_method { pub fn [] (&mut self, index: usize) -> Result<[], JsError> { catch_panic_result(|| { self.0.get::]>(index) - .unwrap() - .map_err(into_js_error) + .map_or_else( + || Err(JsError::new(&format!("Index {index} is out of bounds"))), + |a| a.map_err(into_js_error), + ) .map([]) }) } @@ -1003,8 +1005,10 @@ macro_rules! define_expander_get_method { pub fn [] (&mut self, index: usize) -> Result<[], JsError> { catch_panic_result(|| { self.0.get::]>(index) - .unwrap() - .map_err(into_js_error) + .map_or_else( + || Err(JsError::new(&format!("Index {index} is out of bounds"))), + |a| a.map_err(into_js_error), + ) .map([]) }) } @@ -1026,8 +1030,10 @@ impl CompactCiphertextListExpander { catch_panic_result(|| { self.0 .get::(index) - .unwrap() - .map_err(into_js_error) + .map_or_else( + || Err(JsError::new(&format!("Index {index} is out of bounds"))), + |a| a.map_err(into_js_error), + ) .map(FheBool) }) }