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

Implement Error::source for h2::Error. #462

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 1 addition & 7 deletions src/codec/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::frame::{Reason, StreamId};

use std::{error, fmt, io};
use std::{fmt, io};

/// Errors that are received
#[derive(Debug)]
Expand Down Expand Up @@ -73,8 +73,6 @@ impl From<io::Error> for RecvError {
}
}

impl error::Error for RecvError {}

impl fmt::Display for RecvError {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
use self::RecvError::*;
Expand All @@ -89,8 +87,6 @@ impl fmt::Display for RecvError {

// ===== impl SendError =====

impl error::Error for SendError {}

impl fmt::Display for SendError {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
use self::SendError::*;
Expand All @@ -117,8 +113,6 @@ impl From<UserError> for SendError {

// ===== impl UserError =====

impl error::Error for UserError {}

impl fmt::Display for UserError {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
use self::UserError::*;
Expand Down
9 changes: 8 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,11 @@ impl fmt::Display for Error {
}
}

impl error::Error for Error {}
impl error::Error for Error {
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match self.kind {
Kind::Io(ref e) => Some(e),
goffrie marked this conversation as resolved.
Show resolved Hide resolved
_ => None,
}
}
}