From 69d3e0e6564b416637978a69f0a035066aea4759 Mon Sep 17 00:00:00 2001 From: FxQnLr Date: Wed, 10 Apr 2024 20:15:39 +0200 Subject: Closes #30 and #27. At least a little --- src/error.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/error.rs') diff --git a/src/error.rs b/src/error.rs index 8a011bf..2d70592 100644 --- a/src/error.rs +++ b/src/error.rs @@ -7,7 +7,7 @@ use mac_address::MacParseError; use serde_json::json; use utoipa::ToSchema; use std::io; -use tracing::error; +use tracing::{error, warn}; #[derive(Debug, thiserror::Error, ToSchema)] pub enum Error { @@ -50,15 +50,20 @@ pub enum Error { impl IntoResponse for Error { fn into_response(self) -> Response { - error!("{}", self.to_string()); + // error!("{}", self.to_string()); let (status, error_message) = match self { Self::Json { source } => { error!("{source}"); (StatusCode::INTERNAL_SERVER_ERROR, "Server Error") } Self::Io { source } => { - error!("{source}"); - (StatusCode::INTERNAL_SERVER_ERROR, "Server Error") + if source.kind() == io::ErrorKind::NotFound { + warn!("unknown device requested"); + (StatusCode::NOT_FOUND, "Requested device not found") + } else { + error!("{source}"); + (StatusCode::INTERNAL_SERVER_ERROR, "Server Error") + } } Self::ParseHeader { source } => { error!("{source}"); -- cgit v1.2.3