aboutsummaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs13
1 files changed, 9 insertions, 4 deletions
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;
7use serde_json::json; 7use serde_json::json;
8use utoipa::ToSchema; 8use utoipa::ToSchema;
9use std::io; 9use std::io;
10use tracing::error; 10use tracing::{error, warn};
11 11
12#[derive(Debug, thiserror::Error, ToSchema)] 12#[derive(Debug, thiserror::Error, ToSchema)]
13pub enum Error { 13pub enum Error {
@@ -50,15 +50,20 @@ pub enum Error {
50 50
51impl IntoResponse for Error { 51impl IntoResponse for Error {
52 fn into_response(self) -> Response { 52 fn into_response(self) -> Response {
53 error!("{}", self.to_string()); 53 // error!("{}", self.to_string());
54 let (status, error_message) = match self { 54 let (status, error_message) = match self {
55 Self::Json { source } => { 55 Self::Json { source } => {
56 error!("{source}"); 56 error!("{source}");
57 (StatusCode::INTERNAL_SERVER_ERROR, "Server Error") 57 (StatusCode::INTERNAL_SERVER_ERROR, "Server Error")
58 } 58 }
59 Self::Io { source } => { 59 Self::Io { source } => {
60 error!("{source}"); 60 if source.kind() == io::ErrorKind::NotFound {
61 (StatusCode::INTERNAL_SERVER_ERROR, "Server Error") 61 warn!("unknown device requested");
62 (StatusCode::NOT_FOUND, "Requested device not found")
63 } else {
64 error!("{source}");
65 (StatusCode::INTERNAL_SERVER_ERROR, "Server Error")
66 }
62 } 67 }
63 Self::ParseHeader { source } => { 68 Self::ParseHeader { source } => {
64 error!("{source}"); 69 error!("{source}");