mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-14 05:21:24 +00:00
js-sys: Catch exceptions thrown in Reflect APIs
Proxies passed to Reflect APIs can throw for any of these operations and it is a bit of a mess.
This commit is contained in:
@ -1210,11 +1210,13 @@ impl ToTokens for ast::DictionaryField {
|
||||
(quote! {
|
||||
pub fn #name(&mut self, val: #ty) -> &mut Self {
|
||||
use wasm_bindgen::JsValue;
|
||||
::js_sys::Reflect::set(
|
||||
let r = ::js_sys::Reflect::set(
|
||||
self.obj.as_ref(),
|
||||
&JsValue::from(stringify!(#name)),
|
||||
&JsValue::from(val),
|
||||
);
|
||||
debug_assert!(r.is_ok(), "setting properties should never fail on our dictionary objects");
|
||||
let _ = r;
|
||||
self
|
||||
}
|
||||
}).to_tokens(tokens);
|
||||
|
Reference in New Issue
Block a user