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

Improve error handling #400

Open
CaliViking opened this issue Nov 17, 2024 · 1 comment
Open

Improve error handling #400

CaliViking opened this issue Nov 17, 2024 · 1 comment

Comments

@CaliViking
Copy link

Thank you for creating this library.
There is a feature that I am struggling with. The library uses anyhow for error handling, this makes it hard to programmatically handle errors as I have to downcast errors to the actual errors. An example is init_file(). There are a few issues with this:

  • I have to know what I can downcast to. The only way to find out is to dig around and experiment.
  • The approach is counter to how I understand the intent of Rust. Rust is supposed to be explicit.
  • I believe it is counter to how anyhow is intended to be used. My understanding is that anyhow is intended for top-level error handling at the application level, not error handling at a library level.

I struggle with error handling at other levels as well. How do I programmatically detect that logging has failed? Nothing is returned from error!(), warn!(), info!() macros.

I am not sure if this is a feature request, a bug, or just me misunderstanding how to use Rust and log4rs.

Thanks in advance!

@bconn98
Copy link
Collaborator

bconn98 commented Dec 31, 2024

I think you're right and we should probably be using thiserror in most of these places. I would need to take a deeper look. But it could also solve some of the issues we were talking about in #367.

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

No branches or pull requests

2 participants