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

Make diagnostic methods dynamic on error #9037

Merged
merged 1 commit into from
Nov 12, 2024
Merged

Make diagnostic methods dynamic on error #9037

merged 1 commit into from
Nov 12, 2024

Conversation

charliermarsh
Copy link
Member

Summary

I need these to accept "any error".

@charliermarsh charliermarsh added the internal A refactor or improvement that is not user-facing label Nov 12, 2024
Copy link
Member

@konstin konstin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me (i'll let andrew have the final word), i just wanted to note that this sounds a lot like the abstraction anyhow::Error builds.

Copy link
Member

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM. (What is the motivation?) This is the same way std::io::Error::other works: https://doc.rust-lang.org/std/io/struct.Error.html#method.other

You could use an anyhow::Error here, but the main advantage of that type is to build up a causal error chain. I think we're mostly doing that via thiserror, so I don't see much advantage to using it here.

@charliermarsh
Copy link
Member Author

charliermarsh commented Nov 12, 2024

The motivation here is that I want to be able to pass in either Box<uv_diagnostic::Error> or Arc<uv_diagnostic::Error>... I can't clone, and I can't take a reference because I then need the type to be a field on the inner struct Error I create within these methods, and using a non-static lifetime gives me: non-static lifetimes are not allowed in the source of an error, because std::error::Error requires the source is dyn Error + 'static

@charliermarsh charliermarsh enabled auto-merge (squash) November 12, 2024 14:53
@charliermarsh charliermarsh merged commit b780155 into main Nov 12, 2024
64 checks passed
@charliermarsh charliermarsh deleted the charlie/gen branch November 12, 2024 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal A refactor or improvement that is not user-facing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants