Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking Change: Change prompt function error return type #22

Closed
yaahc opened this issue Aug 26, 2021 · 3 comments
Closed

Breaking Change: Change prompt function error return type #22

yaahc opened this issue Aug 26, 2021 · 3 comments

Comments

@yaahc
Copy link

yaahc commented Aug 26, 2021

Is your feature request related to a problem? Please describe.

I'm testing out inquire in a cli app of mine and at least initially I want to just propagate errors back to main and print them with eyre::Report but the current choice of error return type (Box<dyn Error>) is making this impossible. The issue is two fold. The main issue being that Box<dyn Error> doesn't implement the Error trait so it can't be converted into an eyre::Report through From. I could work around this normally by using the eyre! macro to manually convert the boxed error into a report but this doesn't work because Box<dyn Error> also doesn't implement Send or Sync, which is required to be stored in an eyre::Report at all. This second problem could be fixed by just changing the signature to Box<dyn Error + Send + Sync + 'static> but that still wouldn't solve the From incompatibility, which is intrinsic to Box itself.

Describe the solution you'd like

Ideally I'd recommend introducing your own Error type and implement the Error trait for it. It's too early for me to say yet how it should be structured or what interface it should present, other than an opaque error type that implements Send, Sync, and Error. Ideally I'd start there, even if the Error type internally just stores a Box<dyn Error + Send + Sync + 'static> and is used the same way the current error type is.

@mikaelmello
Copy link
Owner

Hi! At the moment we do use a custom error type that is returned on all prompts: InquireError.

I also tried to see if the current implementation is missing something, implementing this PoC: https://github.com/mikaelmello/eyre-inquire-poc. But it all seems to be working.

I'm not sure if I missed anything from your issue, could you provide some examples?

Also, I added a custom error type on v0.0.4, so I considered that you might be using a version older than that, which would make me very surprised to know people knew about the lib back then!

@yaahc
Copy link
Author

yaahc commented Aug 26, 2021

Also, I added a custom error type on v0.0.4, so I considered that you might be using a version older than that, which would make me very surprised to know people knew about the lib back then!

I apparently somehow pulled in 0.0.2 even though I added it just last night using cargo edit, which I assumed would pull in the latest version. I'm guessing my copy of the index is out of date, sorry for the bother!

@yaahc yaahc closed this as completed Aug 26, 2021
@mikaelmello
Copy link
Owner

No bother at all! Please let me know if you have any other issues. The last couple versions (specially 0.0.8) included huge rewrites for new features :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants