-
Notifications
You must be signed in to change notification settings - Fork 85
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 Report compatible with std::error::Error based types #1746
Comments
Thanks for creating the issue! I just wanted to note that it may take a bit longer to resolve/respond to the issue. Most of the people at HASH (and other contributors) are currently on Christmas/New Years vacation.🎄 Once everyone is back from enjoying some time with their close ones we'll be sure to take a closer look and respond properly! Sorry for the inconvenience. |
Hi @mayabyte and thanks for filing this issue! We’ve been looking into ways to improve the ergonomics of using We’ve experimented with a few other approaches and wonder if providing ways to turn the fn into_error(self) -> impl Error + Send + Sync + 'static;
fn as_error(&self) -> &impl Error + Send + Sync + 'static; Do you think this would help in situations such as yours? |
I definitely think those would help, but having to sprinkle In the absence of other ideas, that problem with making |
The implementation of Yes, this could theoretically be solved by specialization, but there are a few drawbacks here. Specialization with a |
The changes landed on |
Awesome! Thanks so much for your work on this 😄 |
|
Related Problem
Let's say I have a library crate that uses error-stack for all its errors, and a pre-existing user-facing program that wants to use this library but doesn't want to do a big-bang migration of all its own error handling to use error-stack and may not ever care to - let's say it just uses
Box<dyn Error>
for all its errors.Integrating the library's error types into the application is currently very clumsy and weird, requiring us to either pull the
Context
s out of theReport
s manually, stringify the errors, or some other tedious and undesirable pattern.Proposed Solution
Other error handling libraries provide some conversion options for integrating with std Error that would solve this issue for error-stack. By way of example, eyre has the following:
impl AsRef<dyn Error + 'static> for Report
impl Deref<Target = dyn Error + Send + Sync + 'static> for Report
impl From<Report> for Box<dyn Error + 'static>
Alternatives
One possible alternative is implementing Error directly on Report. I can't tell whether this is deliberately being avoided, but neither eyre or anyhow do this for their error types so I assume there's a good reason not to choose this option.
Additional context
No response
The text was updated successfully, but these errors were encountered: