diff --git a/src/enums/error.rs b/src/enums/error.rs index dceb251..8cbb5e8 100644 --- a/src/enums/error.rs +++ b/src/enums/error.rs @@ -1,3 +1,5 @@ +use std::fmt::Display; + #[derive(Debug)] pub enum Error { @@ -6,4 +8,16 @@ pub enum Error { UnexpectedStatusCode(u16, u16, String), NetworkError(String), 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."), + } + } } \ No newline at end of file