refactor: AppError display impl

This commit is contained in:
Jack Wills
2022-09-06 14:31:55 +00:00
parent d26f58201d
commit d6e2026eec
+9 -9
View File
@@ -16,17 +16,17 @@ pub enum AppError {
/// Convert errors into strings to display /// Convert errors into strings to display
impl fmt::Display for AppError { impl fmt::Display for AppError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let disp = match self { match self {
Self::DockerConnect => "Unable to access docker daemon".to_owned(), Self::DockerConnect => write!(f, "Unable to access docker daemon"),
Self::DockerInterval => "Docker update interval needs to be greater than 0".to_owned(), Self::DockerInterval => write!(f, "Docker update interval needs to be greater than 0"),
Self::InputPoll => "Unable to poll user input".to_owned(), Self::InputPoll => write!(f, "Unable to poll user input"),
Self::Terminal => "Unable to draw to terminal".to_owned(), Self::Terminal => write!(f, "Unable to draw to terminal"),
Self::DockerCommand(s) => format!("Unable to {} container", s), Self::DockerCommand(s) => write!(f, "Unable to {} container", s),
Self::MouseCapture(x) => { Self::MouseCapture(x) => {
let reason = if *x { "en" } else { "dis" }; let reason = if *x { "en" } else { "dis" };
format!("Unable to {}able mouse capture", reason) write!(f, "Unbale to {}able mouse capture", reason)
} }
}; }
write!(f, "{}", disp)
} }
} }