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

build() method's error type isn't Send or Sync #27

Open
asomers opened this issue Jun 14, 2024 · 3 comments
Open

build() method's error type isn't Send or Sync #27

asomers opened this issue Jun 14, 2024 · 3 comments

Comments

@asomers
Copy link

asomers commented Jun 14, 2024

A builder's build() method returns a Result::<_, Box<dyn std::error::Error>> type. That isn't Send or Sync, which makes it difficult to use. For example, it can't be used with anyhow::Context. Would it be possible to make the error type a little bit more specific, like Box<dyn Error + Send + Sync>?

@andoriyu
Copy link
Owner

andoriyu commented Jun 14, 2024

Ah yes, I need re-evaluate error handling in this library a little bit.

@asomers I might replace this error type with anyhow::Error. I think I just did Box<dyn std::error::Error> to focus on other parts and forgot to change it.

btw we're on the same discord server for freebsd, feel free to message me there.

@asomers
Copy link
Author

asomers commented Jun 14, 2024

The author of anyhow doesn't recommend its use in libraries, only in applications. For libraries, he recommends returning a custom enum, possibly generated with thiserror (by the same author).

@andoriyu
Copy link
Owner

The author of anyhow doesn't recommend its use in libraries, only in applications. For libraries, he recommends returning a custom enum, possibly generated with thiserror (by the same author).

I think it's more about can this error be handled or not. I need to take a look at what errors can be returned by builder and see if I can neatly organize it with thiserror or swap to anyhow (closer to how it works now)

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

2 participants