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

Replace uses of anyhow with error types #925

Closed
jplatte opened this issue Feb 6, 2020 · 11 comments · Fixed by #2124
Closed

Replace uses of anyhow with error types #925

jplatte opened this issue Feb 6, 2020 · 11 comments · Fixed by #2124
Labels
A-yew Area: The main yew crate ergonomics

Comments

@jplatte
Copy link
Contributor

jplatte commented Feb 6, 2020

As can be seen in #863, there's not a lot of code that uses anyhow's anyhow! or bail!, and no code at all using its Context trait. Replacing those parts with more explicit error types would make it easier to handle the error cases, while dropping a dependency with a non-trivial amount of runtime magic and hardly complicating the code at all.

@jstarry
Copy link
Member

jstarry commented Feb 6, 2020

Thanks @jplatte, it'd be great to do this before the next release since we're already making breaking changes for the error return types. Would you be willing to tackle this?

@jplatte
Copy link
Contributor Author

jplatte commented Feb 6, 2020

Sure! :)

@jplatte
Copy link
Contributor Author

jplatte commented Feb 6, 2020

Well... Despite the few locations in the code that use anyhow, an error type that could be used in its place would require to be convertible from multiple (de)serialization libraries error types AFAICT. I'm afraid I don't understand that part of yew well enough to implement this change.

@jstarry
Copy link
Member

jstarry commented Feb 8, 2020

@jplatte ah yeah that's tricky. I think we will need to rework the format macros a bit. We could add an error variant to FormatError for each supported format. And those variants could be enabled/disabled using cfg feature flags. Then the macros could use the appropriate error variant for each format

@jplatte
Copy link
Contributor Author

jplatte commented Feb 8, 2020

Sure.. Is there a general overview of the whole format things somewhere? That would help put things in perspective.

@jplatte
Copy link
Contributor Author

jplatte commented Feb 8, 2020

Also, regarding yew::format::nothing::Nothing, what's its purpose? Why is something that represent nothing not convertible to an empty (byte) string and instead always fails conversion to that?

@jstarry
Copy link
Member

jstarry commented Feb 9, 2020

Also, regarding yew::format::nothing::Nothing, what's its purpose?

I'm not a big fan of it, but it's used for GET requests currently. See here:
https://github.com/yewstack/yew/blob/master/examples/npm_and_rest/src/gravatar.rs#L47

Is there a general overview of the whole format things somewhere? That would help put things in perspective.

There isn't. Here's an issue: yewstack/docs#24

@bhgomes
Copy link

bhgomes commented Aug 3, 2021

@jstarry Is there any update on this? I'd be willing to work on it.

@jplatte
Copy link
Contributor Author

jplatte commented Aug 3, 2021

I've read in another issue that the whole format API is just going to be removed, so I think this is being worked on already basically.

@ranile
Copy link
Member

ranile commented Aug 3, 2021

I've read in another issue that the whole format API is just going to be removed, so I think this is being worked on already basically.

It has already been removed on master

@jplatte
Copy link
Contributor Author

jplatte commented Aug 3, 2021

Looks like there is only a single use of anyhow in the main yew crate remaining 👍

https://github.com/yewstack/yew/blob/8fbb1a24cc5cfb9d29b76b106db624892ac898dc/packages/yew/src/utils/mod.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-yew Area: The main yew crate ergonomics
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants