diff options
| author | Max Audron <audron@cocaine.farm> | 2020-04-29 00:00:44 +0200 |
|---|---|---|
| committer | Max Audron <audron@cocaine.farm> | 2020-04-29 00:00:44 +0200 |
| commit | fc64e11cdd35051a2ea87237f548ae0497a2f7f9 (patch) | |
| tree | c57937731898b0ffd66d1d95bb0f181cae568c37 /src/error/mod.rs | |
| parent | finish parsing of primitive types (diff) | |
refactor everything
Diffstat (limited to 'src/error/mod.rs')
| -rw-r--r-- | src/error/mod.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/error/mod.rs b/src/error/mod.rs new file mode 100644 index 0000000..72a9e59 --- /dev/null +++ b/src/error/mod.rs @@ -0,0 +1,37 @@ + #[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::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) +// } +// } |
