diff options
| author | Max Audron <audron@cocaine.farm> | 2020-01-21 16:12:13 +0100 |
|---|---|---|
| committer | Max Audron <audron@cocaine.farm> | 2020-01-21 16:12:13 +0100 |
| commit | b1bae553b620f0a1d71c6be7fa98c10978662907 (patch) | |
| tree | 05d33d9e14d2f960ce071938aa88408aa0e941fc /src/protocol/error | |
| parent | update (diff) | |
le tokio
Diffstat (limited to 'src/protocol/error')
| -rw-r--r-- | src/protocol/error/mod.rs | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/src/protocol/error/mod.rs b/src/protocol/error/mod.rs index 488ae0d..72a9e59 100644 --- a/src/protocol/error/mod.rs +++ b/src/protocol/error/mod.rs @@ -1,28 +1,37 @@ -#[derive(Debug)] -pub enum ErrorKind { + #[derive(Debug, Fail)] +pub enum ProtocolError { + #[fail(display = "message has wrong type")] WrongMsgType, + #[fail(display = "bool value is neither 0 nor 1")] BoolOutOfRange, + #[fail(display = "QVariant is not known")] UnknownVariant, + #[fail(display = "wrong variant has been given")] WrongVariant, + #[fail(display = "io error")] IOError(std::io::Error), + #[fail(display = "could not convert from int")] TryFromIntError(std::num::TryFromIntError), + #[fail(display = "utf8 error")] Utf8Error(std::string::FromUtf8Error), -} + } -impl std::convert::From<std::io::Error> for ErrorKind { - fn from(error: std::io::Error) -> Self { - ErrorKind::IOError(error) - } -} - -impl std::convert::From<std::num::TryFromIntError> for ErrorKind { - fn from(error: std::num::TryFromIntError) -> Self { - ErrorKind::TryFromIntError(error) - } -} - -impl std::convert::From<std::string::FromUtf8Error> for ErrorKind { - fn from(error: std::string::FromUtf8Error) -> Self { - ErrorKind::Utf8Error(error) - } -} +// impl std::error::Error for ErrorKind {} +// +// impl std::convert::From<std::io::Error> for ErrorKind { +// fn from(error: std::io::Error) -> Self { +// ErrorKind::IOError(error) +// } +// } +// +// impl std::convert::From<std::num::TryFromIntError> for ErrorKind { +// fn from(error: std::num::TryFromIntError) -> Self { +// ErrorKind::TryFromIntError(error) +// } +// } +// +// impl std::convert::From<std::string::FromUtf8Error> for ErrorKind { +// fn from(error: std::string::FromUtf8Error) -> Self { +// ErrorKind::Utf8Error(error) +// } +// } |
