Skip to content

Conversation

afranchuk
Copy link

Closes #379.

Copy link
Owner

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. I don't think this is necessarily better. This means if you take anyhow::Error with a backtrace, and convert it to Box<dyn Error>, the resulting error loses the backtrace.

@afranchuk
Copy link
Author

afranchuk commented Apr 3, 2025

That's a fair point. Maybe it would work to make the source of ErrorImpl<E> be E instead of E's source? That way you can still downcast by walking the sources. That also sort of makes sense if you squint, since you are taking some E and making a new sort of error out of it (in this case one with a backtrace attached).

Unfortunately that change may break existing code, though. But on the other hand you could also make that behavior only occur when it's converted to a boxed error to limit the extent of the change in behavior.

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

Successfully merging this pull request may close these issues.

Conversion to Box<dyn Error> loses downcast ability
2 participants