aboutsummaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
authorFxQnLr <[email protected]>2024-04-15 20:33:32 +0200
committerFxQnLr <[email protected]>2024-04-15 20:33:32 +0200
commitd3cf93fb6c9b7e0faf9b7907328f0a042009e164 (patch)
treea55ec4f56e16de701c6764b559c776b38bc11637 /src/error.rs
parentb615f6e34e084d520dcc301058b5926074188500 (diff)
downloadwebol-d3cf93fb6c9b7e0faf9b7907328f0a042009e164.tar
webol-d3cf93fb6c9b7e0faf9b7907328f0a042009e164.tar.gz
webol-d3cf93fb6c9b7e0faf9b7907328f0a042009e164.zip
Closes #35. Entry of Ip optional, error on ping request without saved ip
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs8
1 files changed, 7 insertions, 1 deletions
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 {
46 #[from] 46 #[from]
47 source: io::Error, 47 source: io::Error,
48 }, 48 },
49
50 #[error("No ip set for device but ping requested")]
51 NoIpOnPing,
49} 52}
50 53
51impl IntoResponse for Error { 54impl IntoResponse for Error {
52 fn into_response(self) -> Response { 55 fn into_response(self) -> Response {
53 // error!("{}", self.to_string());
54 let (status, error_message) = match self { 56 let (status, error_message) = match self {
55 Self::Json { source } => { 57 Self::Json { source } => {
56 error!("{source}"); 58 error!("{source}");
@@ -80,6 +82,10 @@ impl IntoResponse for Error {
80 Self::IpParse { source } => { 82 Self::IpParse { source } => {
81 error!("{source}"); 83 error!("{source}");
82 (StatusCode::INTERNAL_SERVER_ERROR, "Server Error") 84 (StatusCode::INTERNAL_SERVER_ERROR, "Server Error")
85 },
86 Self::NoIpOnPing => {
87 error!("Ping requested but no ip given");
88 (StatusCode::BAD_REQUEST, "No Ip saved for requested device, but device started")
83 } 89 }
84 }; 90 };
85 let body = Json(json!({ 91 let body = Json(json!({