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

Retiring anomaly #669

Closed
tarcieri opened this issue Nov 11, 2020 · 18 comments · Fixed by #923
Closed

Retiring anomaly #669

tarcieri opened this issue Nov 11, 2020 · 18 comments · Fixed by #923

Comments

@tarcieri
Copy link
Contributor

FYI, I'm planning on deprecating the anomaly error handling crate, which tendermint-rs presently uses.

There have been a number of error handling crates that have surpassed it coming out of the error handling working group.

I would suggest eyre as a replacement.

@romac
Copy link
Member

romac commented Nov 12, 2020

Great news! Will abscissa move to eyre as well? If so, any ETA on that?

@tarcieri
Copy link
Contributor Author

@romac I believe @yaahc has a branch which moves Abscissa to (color-)eyre but I'm not sure about the status of that

@tarcieri
Copy link
Contributor Author

FYI, here's an example of moving from anomaly to eyre: iqlusioninc/crates#555

@romac
Copy link
Member

romac commented Nov 12, 2020

@tarcieri Thanks for the pointers!

PS: By the way, by "great news" I didn't mean to imply that anomaly was a bad library, but rather that since the ecosystem seems to have moved away from it in favor of eyre (something I've been considering doing for our libs as well), I was happy to see that you were now recommending it as well over anomaly.

@tarcieri
Copy link
Contributor Author

No worries, I’m happy there are better libraries emerging in this space as well

@thanethomson thanethomson added this to the v0.18 milestone Nov 19, 2020
@ebuchman
Copy link
Member

Re #160 (closed for this issue) we should still write a small ADR for error handling in the repo. The comment #150 (comment) provides a great starting point for an ADR. Also relevant #158 (comment)

@tarcieri tarcieri reopened this Nov 21, 2020
@ebuchman ebuchman modified the milestones: v0.18, v0.19 Nov 24, 2020
@thanethomson thanethomson removed this from the v0.20 milestone Apr 7, 2021
@hdevalence hdevalence mentioned this issue Apr 20, 2021
5 tasks
@DaviRain-Su
Copy link

Can we use anyhow to handle error?

@tony-iqlusion
Copy link
Collaborator

Some other downstream projects have switched to eyre, which is a fork of anyhow. eyre supports adding arbitrary context objects to errors.

I don't believe it supports the same hacks as anyhow to work in no_std contexts (I'm surprised to learn those actually landed). Instead, my understanding is a no_std path for eyre relies on actually moving the Error trait into libcore, which is currently blocked on exposing Backtrace from libcore: rust-lang/rust#77384

@yaahc
Copy link

yaahc commented May 24, 2021

I don't believe it supports the same hacks as anyhow to work in no_std contexts (I'm surprised to learn those actually landed). Instead, my understanding is a no_std path for eyre relies on actually moving the Error trait into libcore, which is currently blocked on exposing Backtrace from libcore: rust-lang/rust#77384

I'm not sure if they added new hacks but there was some no_std support originally that we tried bringing over with eyre but I think it was broken at the time, not sure. I don't recall removing it but I may have. Either way yea, I don't personally plan on implementing any hacks for no_std but I think any hacks that work for anyhow could be applied to eyre and so I'd likely merge any PR's to bring them back to feature parity, since my goal with eyre is always to be a drop in replacement for anyhow with more customizable reporting.

@tony-iqlusion
Copy link
Collaborator

If there's a path to getting the Error trait into either libcore or liballoc, it seems like waiting for that is the right way to go with eyre

@yaahc
Copy link

yaahc commented May 24, 2021

If there's a path to getting the Error trait into either libcore or liballoc, it seems like waiting for that is the right way to go with eyre

Sure, but what I mean is that the no_std support that anyhow provides is already independent of the Error trait, you can only use anyhow::Error and construct them from Display types iirc. Alongside that you still need alloc support to use anyhow/eyre. So I think whether we wait for Error in core or not really depends on what you mean by getting libcore or liballoc support. It may be that the support provided by anyhow is already insufficient or that the support you need from eyre is already very nearly there.

@tony-iqlusion
Copy link
Collaborator

tony-iqlusion commented May 24, 2021

In no_std mode, anyhow defines its own private (fake) StdError trait in absence of a real std::error::Error trait:

https://github.com/dtolnay/anyhow/blob/704622f/src/lib.rs#L265-L270

Since it's not re-exported, it's not possible to use dyn Error, and with it Box<dyn Error> even when liballoc is available.

@yaahc
Copy link

yaahc commented May 24, 2021

Ack, that's what I remember it having. That's what I was referring to when I said you can only construct anyhow::Error with Display types, the Error based APIs via Error::new and Error::from both get disabled when compiled for no_std. Just checked and we did actively remove that, and I'm guessing that adding back just that wouldn't be the easiest thing. Now you have me wondering if there's a low hanging fruit of moving the error trait just into liballoc that could be done today that would enable anyhow and eyre to use Error in no_std.

@tony-iqlusion
Copy link
Collaborator

Now you have me wondering if there's a low hanging fruit of moving the error trait just into liballoc that could be done today that would enable anyhow and eyre to use Error in no_std.

That would be amazing!

@DaviRain-Su
Copy link

Ack, that's what I remember it having. That's what I was referring to when I said you can only construct anyhow::Error with Display types, the Error based APIs via Error::new and Error::from both get disabled when compiled for no_std. Just checked and we did actively remove that, and I'm guessing that adding back just that wouldn't be the easiest thing. Now you have me wondering if there's a low hanging fruit of moving the error trait just into liballoc that could be done today that would enable anyhow and eyre to use Error in no_std.

cool, amazing.

@DaviRain-Su
Copy link

@yaahc Want to know if you've fixed this feature?

@yaahc
Copy link

yaahc commented Jun 1, 2021

@yaahc Want to know if you've fixed this feature?

It's not fixed yet, I forgot that the backtrace part of the Error api still needs a full solution rather than just a proof of concept proposal and getting that fully sorted is necessary before we could even do a partial move to alloc.

@DaviRain-Su
Copy link

It's not fixed yet, I forgot that the backtrace part of the Error api still needs a full solution rather than just a proof of concept proposal and getting that fully sorted is necessary before we could even do a partial move to alloc.

Thank you for your answer

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

Successfully merging a pull request may close this issue.

7 participants