-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Include panic payload string in JoinError
display/debug output
#6749
Comments
I think the change is a good idea, but you will most likely need unsafe to look inside the |
I didn't realize that Something like this? impl SyncWrapper<Box<dyn Any + Send>> {
/// Attempt to downcast using [`Any::downcast_ref()`] to a type that is known to be `Sync`.
pub fn downcast_ref_sync<T: Any + Sync>(&self) -> Option<&T> {
// SAFETY: if the downcast fails, the inner value is not touched,
// so no thread-safety violation can occur.
self.0.downcast_ref()
}
} |
Yes, that looks good to me. |
Is your feature request related to a problem? Please describe.
When building Tokio applications, we almost always want to capture a
tokio::task::JoinError
and turn it into another error, e.g.eyre::Report
and bubble it up. We don't generally explicitly cancel tasks, so the main possible source of errors is panics.Because
JoinError
doesn't include the panic payload in itsDebug
orDisplay
output, we end up with the same copy-pasted conversion functions in every single project:Describe the solution you'd like
Include the logic similar to
panic_payload_to_str()
shown above to extract the payload string of a panic, if applicable, and include it in theDebug
andDisplay
output ofJoinError
.I'd be happy to open a PR. I thought about just doing that, but I figured it'd be worth opening an issue to discuss first. I couldn't find an existing one.
Describe alternatives you've considered
{:#}
,{:#?}
)?
operator when converting toeyre::Report
/anyhow::Error
panic_payload_to_str()
as a method onJoinError
(open to bikeshedding)std::panic::payload_str()
Additional context
N/A
The text was updated successfully, but these errors were encountered: