From d3cf93fb6c9b7e0faf9b7907328f0a042009e164 Mon Sep 17 00:00:00 2001 From: FxQnLr Date: Mon, 15 Apr 2024 20:33:32 +0200 Subject: Closes #35. Entry of Ip optional, error on ping request without saved ip --- src/error.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/error.rs') diff --git a/src/error.rs b/src/error.rs index 2d70592..b8a078b 100644 --- a/src/error.rs +++ b/src/error.rs @@ -46,11 +46,13 @@ pub enum Error { #[from] source: io::Error, }, + + #[error("No ip set for device but ping requested")] + NoIpOnPing, } impl IntoResponse for Error { fn into_response(self) -> Response { - // error!("{}", self.to_string()); let (status, error_message) = match self { Self::Json { source } => { error!("{source}"); @@ -80,6 +82,10 @@ impl IntoResponse for Error { Self::IpParse { source } => { error!("{source}"); (StatusCode::INTERNAL_SERVER_ERROR, "Server Error") + }, + Self::NoIpOnPing => { + error!("Ping requested but no ip given"); + (StatusCode::BAD_REQUEST, "No Ip saved for requested device, but device started") } }; let body = Json(json!({ -- cgit v1.2.3