uniffi-rs icon indicating copy to clipboard operation
uniffi-rs copied to clipboard

Should proc-macros support mapping errors?

Open bendk opened this issue 2 years ago • 3 comments

Proc-macro and UDL-based generation disagree on how to handle functions returning errors.

UDL-based generation adds a .map_err(Into::into) call, which allows the exported function to return any error that maps into actual UniFFI error type. Proc-macros don't do that.

Should we add proc-macro support for the map_err call or deprecate/remove it?

bendk avatar Sep 12 '23 17:09 bendk

I think this might help in having a "regular" Rust API exported via UniFFI, but I'm not sure. If we want to support it, I guess it will be in the form of an attribute like #[uniffi::method(err_into = FFiErrorType)], or do you have different ideas?

jplatte avatar Sep 12 '23 17:09 jplatte

Yeah, that's what I'm thinking as well.

bendk avatar Sep 12 '23 18:09 bendk

I have trouble making throwing coroutines with .udl file because of this... it tries to call map_err to the returned future. I used [Async, Throws=MyError].

paxbun avatar Nov 21 '23 09:11 paxbun