Finschia / cosmwasm

Fast and reusable WebAssembly smart contract runtime(and library) for finschia-sdk.
Apache License 2.0
27 stars 14 forks source link

Enable to catch serde error in dynamic link #323

Open loloicci opened 1 year ago

loloicci commented 1 year ago

If serializations or deserializations fail in the code generated by macro #[dynamiclink] or #[callablepoints], the Err is unwrapped, and WASM panics. I suggest improving the macros to enable generated functions to return Err(e) (e is made from serde::Error).

Design

It is not clear how to declare that "this function returns Err(e) when (de)serialization fails".

  1. add an attribute like #[serde_err] to the function
  2. all functions returning Result<T, E> returns Err(e)

2's compile is sometimes errors unexpectedly if serde::Error cannot automatically cast into E