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

Remove deprecated Error::description and Error::cause #933

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 7 additions & 24 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,7 @@ impl core::fmt::Display for Unspecified {
}

#[cfg(feature = "std")]
impl std::error::Error for Unspecified {
#[inline]
fn cause(&self) -> Option<&dyn std::error::Error> {
None
}

fn description(&self) -> &str {
Self::description_()
Copy link
Owner

Choose a reason for hiding this comment

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

description_() should be removed and inlined into the Display implementation.

}
}
impl std::error::Error for Unspecified {}

impl From<untrusted::EndOfInput> for Unspecified {
fn from(_: untrusted::EndOfInput) -> Self {
Expand All @@ -117,10 +108,10 @@ impl From<core::array::TryFromSliceError> for Unspecified {

/// An error parsing or validating a key.
///
/// The `Display` implementation and `<KeyRejected as Error>::description()`
/// will return a string that will help you better understand why a key was
/// rejected change which errors are reported in which situations while
/// minimizing the likelihood that any applications will be broken.
/// The `Display` implementation will return a string that will help you better
/// understand why a key was rejected change which errors are reported in which
/// situations while minimizing the likelihood that any applications will be
/// broken.
///
/// Here is an incomplete list of reasons a key may be unsupported:
///
Expand Down Expand Up @@ -149,7 +140,7 @@ impl From<core::array::TryFromSliceError> for Unspecified {
pub struct KeyRejected(&'static str);

impl KeyRejected {
/// The value returned from <Self as std::error::Error>::description()
/// The value is used in Display
pub fn description_(&self) -> &'static str {
Copy link
Owner

Choose a reason for hiding this comment

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

Again, I think description_() should be removed; its code should be inlined into the Display implementation.

self.0
}
Expand Down Expand Up @@ -200,15 +191,7 @@ impl KeyRejected {
}

#[cfg(feature = "std")]
impl std::error::Error for KeyRejected {
fn cause(&self) -> Option<&dyn std::error::Error> {
None
}

fn description(&self) -> &str {
self.description_()
}
}
impl std::error::Error for KeyRejected {}

impl core::fmt::Display for KeyRejected {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
Expand Down