hyper icon indicating copy to clipboard operation
hyper copied to clipboard

Make Error::source() types that come from unstable dependencies wrapped in an Opaque type

Open seanmonstar opened this issue 3 years ago • 3 comments

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>().

seanmonstar avatar May 20 '22 17:05 seanmonstar

Is it not going to expose sources either? Since the opaque wrapping can only happen at the first level

sfackler avatar May 20 '22 17:05 sfackler

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.

seanmonstar avatar May 20 '22 23:05 seanmonstar

I filed a proposal for the error handling WG, since that could affect the formatting needed for an "opaque" type.

seanmonstar avatar Aug 29 '22 20:08 seanmonstar

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"?

seanmonstar avatar Sep 11 '23 15:09 seanmonstar

imo that's fine. It's what axum does for extractor rejections. While not great I think its pragmatic and acceptable.

davidpdrsn avatar Sep 11 '23 15:09 davidpdrsn