hyper
hyper copied to clipboard
Make Error::source() types that come from unstable dependencies wrapped in an Opaque type
All sources/causes in hyper::Error should be wrapped in a private Opaque type that still prints (impl Debug and impl Display) the message, but makes the type no longer leak through err.downcast::<Blah>().
Is it not going to expose sources either? Since the opaque wrapping can only happen at the first level
I suppose it "couldn't" expose the next source, since it can't wrap a reference, and exposing it would potentially include unstable dependencies... If the second option in #2844 happens, the unexposed sources would still be printable at least.
I filed a proposal for the error handling WG, since that could affect the formatting needed for an "opaque" type.
I suppose a question to consider is: is it fair to simply document "The types in Error::source() are not part of the public API, and are subject to change at any time"?
imo that's fine. It's what axum does for extractor rejections. While not great I think its pragmatic and acceptable.