#Better errors

5 messages · Page 1 of 1 (latest)

light hull
#

I use the crate eyre (similar to anyhow) to return results from commands.
I use it instead of anyhow because it returns errors with nice backtrace (similar to unwrap) which is useful.
The problem is that eyre (and anyhow) doesn't implement Serialize so I can't propagate errors with ? in tauri commands.

So I created a fork to eyre and implemented serialize for their Report type.
Finally I can propagate almost any error in tauri commands.
But the current implementation use .to_string() and it turns out that their fmt::Display is useless, it doesn't show summarized backtrace, but just the top error string.
if I change a bit the implementation of the serializer to return format!("{:?}", ...) then finally I get meaningful errors in the browser.
But I'm not sure if it's right to return it like that by default, and I'm looking for advices, how do we get into the point where we can easily propagate errors in tauri projects?

crimson imp
#

If you want to set different levels of verbosity for example for debug vs release builds you could set that level in a global OnceCell and then read that in the serialize fn.

light hull
crimson imp
#

well, you must have something (if the crates don't implement serialize) :/