aboutsummaryrefslogtreecommitdiff
path: root/src/protocol/error/mod.rs
diff options
context:
space:
mode:
authorMax Audron <audron@cocaine.farm>2020-01-17 12:30:27 +0100
committerMax Audron <audron@cocaine.farm>2020-01-17 12:30:27 +0100
commit07561131e9ec3d1f3aef99a8df2e3b9b7282156e (patch)
tree72830d0eff2dd04698cc9ae9d698d31cc139056f /src/protocol/error/mod.rs
parentfinish main parsing (diff)
add error handling
Diffstat (limited to '')
-rw-r--r--src/protocol/error/mod.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/protocol/error/mod.rs b/src/protocol/error/mod.rs
new file mode 100644
index 0000000..488ae0d
--- /dev/null
+++ b/src/protocol/error/mod.rs
@@ -0,0 +1,28 @@
+#[derive(Debug)]
+pub enum ErrorKind {
+ WrongMsgType,
+ BoolOutOfRange,
+ UnknownVariant,
+ WrongVariant,
+ IOError(std::io::Error),
+ TryFromIntError(std::num::TryFromIntError),
+ 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)
+ }
+}