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

Issue with init_file using anyhow instead of thiserror #205

Closed
0xpr03 opened this issue Dec 30, 2020 · 6 comments
Closed

Issue with init_file using anyhow instead of thiserror #205

0xpr03 opened this issue Dec 30, 2020 · 6 comments

Comments

@0xpr03
Copy link

0xpr03 commented Dec 30, 2020

Currently init_file does use anyhow which does not implement std::error::Error.
Thus it is impossible to directly convert from this type or use ? on it when using anything else than anyhow.

In my case this is stable_eyre for backtraces.
the trait std::error::Erroris not implemented foranyhow::Error``

I'd suggest using thiserror which as stated per docs is more suited to libs versus applications.

See also eyre-rs/eyre#31
and dtolnay/anyhow#28

0xpr03 added a commit to 0xpr03/clantool that referenced this issue Dec 31, 2020
Don't upgrade log4rs due to estk/log4rs#205

Signed-off-by: Aron Heinecke <aron.heinecke@t-online.de>
@estk
Copy link
Owner

estk commented Mar 30, 2021

@0xpr03 I agree that in general thiserror is more suitable for libs. In our case, we actually cannot enumerate all of our errors since we have a plugin interface that allows people to extend log4rs (such as using syslog). So, unfortunately, it's not possible to use thiserror.

@estk estk closed this as completed Mar 30, 2021
@0xpr03
Copy link
Author

0xpr03 commented Mar 30, 2021

@0xpr03 I agree that in general thiserror is more suitable for libs. In our case, we actually cannot enumerate all of our errors since we have a plugin interface that allows people to extend log4rs (such as using syslog). So, unfortunately, it's not possible to use thiserror.

You could also settle for anyhow, it's the non-specific version with the same constraints.

@estk estk reopened this Mar 30, 2021
@estk
Copy link
Owner

estk commented Mar 30, 2021

@0xpr03 maybe I don't understand your question but we are using anyhow: https://docs.rs/log4rs/1.0.0/log4rs/append/trait.Append.html#tymethod.append

@0xpr03
Copy link
Author

0xpr03 commented Mar 30, 2021

Ah wait, I just realized my error, I mixed up another issue. I guess we'd have to somehow add the StdError trait ? I'll re-investigate this tomorrow hopefully and try to come up with a better solution. Meanwhile I'll close this prevent further noise.

@0xpr03 0xpr03 closed this as completed Mar 30, 2021
@0xpr03
Copy link
Author

0xpr03 commented Jun 8, 2021

What I mean was to use an std:error, fixed size approach like thiserror

@0xpr03 0xpr03 reopened this Jun 8, 2021
@OvermindDL1
Copy link

OvermindDL1 commented Jun 9, 2021

thiserror supports having an error case of an unknown error type, can just box an stderror or take a reference to it if its possible in that situation (rarely), which is what anyhow does internally.

@estk estk closed this as completed Apr 22, 2022
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

3 participants