Skip to content
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

Impl/error source #144

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Impl/error source #144

wants to merge 3 commits into from

Conversation

eldesh
Copy link

@eldesh eldesh commented Dec 18, 2019

I added source method of std::error::Error for Error and imp::openssl::Error.
This PR enable users downcast_ref errors like:

let tls_error: native_tls::Error = ...
if let Some(ref ssl_error) =tls_error
    .source()
    .and_then(|e| e.downcast_ref::<openssl::ssl::Error>())
{
    ...
}

@@ -127,12 +127,19 @@ impl error::Error for Error {
}
}

fn cause(&self) -> Option<&error::Error> {
fn cause(&self) -> Option<&dyn error::Error> {
Copy link
Owner

Choose a reason for hiding this comment

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

You can just remove the cause implementations - they'll delegate to source anyway.

@sfackler
Copy link
Owner

You should be aware that we don't consider the underlying TLS implementations to be public API. We can and will e.g. upgrade versions without a breaking release.

@eldesh
Copy link
Author

eldesh commented Dec 25, 2019

It is advisable to provide precise error type from this crate.
But acquiring inner error type using source method is reasonable.
Also, the method is required for standard error trait.
A user code depends on an inner error type, breaking can't be avoided.

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.

2 participants