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) + } +}