Closed steos closed 1 year ago
When deserializing a tsified struct from a JS value the serde error message gets lost. With this change the error message gets propagated as the JS exception message.
Consider this example:
#[derive(Debug, Serialize, Deserialize, Tsify)] #[tsify(into_wasm_abi, from_wasm_abi)] pub struct Foo { foo: String } #[wasm_bindgen] pub fn foobar(params: Foo) -> Result<String, JsError> { Ok(String::from("hello")) }
When calling foobar from JS with invalid Foo
foobar
Foo
before:
foobar() // Uncaught Error: `unwrap_throw` failed foobar({}) // Uncaught Error: `unwrap_throw` failed
after:
foobar() // Uncaught Error: Error: invalid type: unit value, expected struct Foo foobar({}) // Uncaught Error: Error: missing field `foo`
Sorry for the late reply. Thank you!
When deserializing a tsified struct from a JS value the serde error message gets lost. With this change the error message gets propagated as the JS exception message.
Consider this example:
When calling
foobar
from JS with invalidFoo
before:
after: