cosmwasm icon indicating copy to clipboard operation
cosmwasm copied to clipboard

Enable to catch serde error in dynamic link

Open loloicci opened this issue 11 months ago • 0 comments

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

loloicci avatar Jul 28 '23 11:07 loloicci