Implemented display for erorr

This commit is contained in:
Franklin 2022-08-26 22:49:44 -04:00
parent 8e49e7e7f1
commit 62c1937f11

View File

@ -1,3 +1,5 @@
use std::fmt::Display;
#[derive(Debug)] #[derive(Debug)]
pub enum Error { pub enum Error {
@ -7,3 +9,15 @@ pub enum Error {
NetworkError(String), NetworkError(String),
SerdeError SerdeError
} }
impl Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Error::CommunicatorError(message) => write!(f, "Error of type Communicator Error. Message: {}", message),
Error::UknownError => write!(f, "Error of type Uknown Error."),
Error::UnexpectedStatusCode(expected, actual, message) => write!(f, "Error of type UnexpectedStatusCode. Expected: {}, Actual: {}, Message: {}", expected, actual, message),
Error::NetworkError(message) => write!(f, "Error of type Network Error. Message: {}", message),
Error::SerdeError => write!(f, "Error of type Serde Error."),
}
}
}