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

Avoid anyhow dependency #119

Closed
jennydaman opened this issue Mar 4, 2024 · 5 comments
Closed

Avoid anyhow dependency #119

jennydaman opened this issue Mar 4, 2024 · 5 comments

Comments

@jennydaman
Copy link

Hello,

I am wondering whether it'd be possible for a future version of reqwest_middleware to leave out the dependency on anyhow::Error.

Middleware(#[from] anyhow::Error),

  • As a "library-level" crate, we should use more specific error enums if possible.
  • In the community there is some shift in preferences and recently some people favor eyre over anyhow.
@LukeMathWalker
Copy link
Collaborator

In the community there is some shift in preferences and recently some people favor eyre over anyhow.

This claim needs a source.
eyre's download count is extremely stable: https://crates.io/crates/eyre
We're looking at 3M recent download for eyre vs 23M recent download for anyhow.

@LukeMathWalker
Copy link
Collaborator

As a "library-level" crate, we should use more specific error enums if possible.

That error variant must be opaque. The only alternative, here, is to define a custom opaque error in request-middleware. What's the benefit, beyond removing a dependency on anyhow?

@jennydaman
Copy link
Author

This claim needs a source

https://blessed.rs/crates (scroll down to “Error Handling”)

What’s the benefit, beyond removing a dependency

Yeah, that’s all. This issue is just to be pedantic

@LukeMathWalker
Copy link
Collaborator

LukeMathWalker commented Mar 6, 2024

This claim needs a source

https://blessed.rs/crates (scroll down to “Error Handling”)

That's someone opinion—they're entitled to it, but blessed.rs has no official sanctioning whatsoever.
Even the "application Vs library" split is quite debatable.

@conradludgate
Copy link
Collaborator

The current middleware design cannot support a non type-erased error system. Some crates will use Box<dyn Error + Send + 'static> for this, but that often plays poorly with anyhow on both ends.

A tower-like service architecture is necessary to support nested error types, but reqwest-middleware has explicitly made the choice to not use that design. Perhaps we could reconsider in future.

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

No branches or pull requests

3 participants