facebookincubator / superconsole

The superconsole crate provides a handler and building blocks for powerful, yet minimally intrusive TUIs. It is cross platform, supporting Windows 7+, Linux, and MacOS. Rustaceans who want to create non-interactive TUIs can use the component composition building block system to quickly deploy their code.
Apache License 2.0
481 stars 14 forks source link

Consider not using anyhow::Error #5

Open wilfreddenton opened 1 year ago

wilfreddenton commented 1 year ago

I recently started using superconsole and I really like it. Thanks for making this! 🙏

The use of anyhow presents a bit of an ergonomics problem however. For example, in my application I use eyre and I have to manually map_err your anyhow errors to eyre::Reports. It seems that under the hood you are using thiserror to define errors. Perhaps these could be brought up to the surface instead of wrapping them in anyhow::Error?

cjhopman commented 1 year ago

One of the challenges is that superconsole needs to propagate errors up from Components. I guess we could resolve that by Component still using anyhow::Result and wrapping any errors in some superconsole error type. I think a better approach may be for the user to configure superconsole with the error type that they want (probably requiring that there's a From for it). I think this would fit nicely with the solution for the #6.

ndmitchell commented 1 year ago

@stepancheg - given the solution to #6 is now landed, how easy it is to do the error generalisation?