Skip to content

Commit baf9d05

Browse files
authored
chore: Use thiserror more (mozilla#3237)
1 parent 042e684 commit baf9d05

2 files changed

Lines changed: 11 additions & 71 deletions

File tree

neqo-bin/src/client/mod.rs

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -49,47 +49,17 @@ pub enum Error {
4949
#[error("argument error: {0}")]
5050
Argument(&'static str),
5151
#[error(transparent)]
52-
Http3(neqo_http3::Error),
52+
Http3(#[from] neqo_http3::Error),
5353
#[error(transparent)]
54-
Io(io::Error),
54+
Io(#[from] io::Error),
5555
#[error(transparent)]
56-
Qlog(qlog::Error),
56+
Qlog(#[from] qlog::Error),
5757
#[error(transparent)]
58-
Transport(neqo_transport::Error),
58+
Transport(#[from] neqo_transport::Error),
5959
#[error("application error: {0}")]
6060
Application(AppError),
6161
#[error(transparent)]
62-
Crypto(neqo_crypto::Error),
63-
}
64-
65-
impl From<neqo_crypto::Error> for Error {
66-
fn from(err: neqo_crypto::Error) -> Self {
67-
Self::Crypto(err)
68-
}
69-
}
70-
71-
impl From<io::Error> for Error {
72-
fn from(err: io::Error) -> Self {
73-
Self::Io(err)
74-
}
75-
}
76-
77-
impl From<neqo_http3::Error> for Error {
78-
fn from(err: neqo_http3::Error) -> Self {
79-
Self::Http3(err)
80-
}
81-
}
82-
83-
impl From<qlog::Error> for Error {
84-
fn from(err: qlog::Error) -> Self {
85-
Self::Qlog(err)
86-
}
87-
}
88-
89-
impl From<neqo_transport::Error> for Error {
90-
fn from(err: neqo_transport::Error) -> Self {
91-
Self::Transport(err)
92-
}
62+
Crypto(#[from] neqo_crypto::Error),
9363
}
9464

9565
impl From<CloseReason> for Error {

neqo-bin/src/server/mod.rs

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -55,45 +55,15 @@ pub enum Error {
5555
#[error("invalid argument: {0}")]
5656
Argument(&'static str),
5757
#[error(transparent)]
58-
Http3(neqo_http3::Error),
58+
Http3(#[from] neqo_http3::Error),
5959
#[error(transparent)]
60-
Io(io::Error),
61-
#[error("qlog error")]
62-
Qlog,
60+
Io(#[from] io::Error),
6361
#[error(transparent)]
64-
Transport(neqo_transport::Error),
62+
Qlog(#[from] qlog::Error),
6563
#[error(transparent)]
66-
Crypto(neqo_crypto::Error),
67-
}
68-
69-
impl From<neqo_crypto::Error> for Error {
70-
fn from(err: neqo_crypto::Error) -> Self {
71-
Self::Crypto(err)
72-
}
73-
}
74-
75-
impl From<io::Error> for Error {
76-
fn from(err: io::Error) -> Self {
77-
Self::Io(err)
78-
}
79-
}
80-
81-
impl From<neqo_http3::Error> for Error {
82-
fn from(err: neqo_http3::Error) -> Self {
83-
Self::Http3(err)
84-
}
85-
}
86-
87-
impl From<qlog::Error> for Error {
88-
fn from(_err: qlog::Error) -> Self {
89-
Self::Qlog
90-
}
91-
}
92-
93-
impl From<neqo_transport::Error> for Error {
94-
fn from(err: neqo_transport::Error) -> Self {
95-
Self::Transport(err)
96-
}
64+
Transport(#[from] neqo_transport::Error),
65+
#[error(transparent)]
66+
Crypto(#[from] neqo_crypto::Error),
9767
}
9868

9969
pub type Res<T> = Result<T, Error>;

0 commit comments

Comments
 (0)