From 00b4e60341ba13ef16f626e77bb403151ba9f093 Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Sun, 7 Jul 2019 13:29:26 +0200 Subject: [PATCH] Add parse error --- src/error.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/error.rs b/src/error.rs index 0f6edf2..49f70cf 100644 --- a/src/error.rs +++ b/src/error.rs @@ -16,6 +16,7 @@ pub(crate) enum Error { Io(std::io::Error), Log(log::SetLoggerError), LogBuilder(log4rs::config::Errors), + Parse(std::num::ParseIntError), Serial(serde_json::Error), } @@ -29,6 +30,7 @@ impl fmt::Display for Error { Error::Io(e) => write!(fmt, "Io({})", e), Error::Log(e) => write!(fmt, "Log({})", e), Error::LogBuilder(e) => write!(fmt, "LogBuilder({})", e), + Error::Parse(e) => write!(fmt, "Parse({})", e), Error::Serial(e) => write!(fmt, "Serial({})", e), } } @@ -91,3 +93,9 @@ impl From for Error { Error::LogBuilder(err) } } + +impl From for Error { + fn from(err: std::num::ParseIntError) -> Self { + Error::Parse(err) + } +}