aboutsummaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
authorFxQnLr <[email protected]>2024-04-15 21:12:04 +0200
committerGitHub <[email protected]>2024-04-15 21:12:04 +0200
commitea4f36ea34a4e425ef23e2ae0d4ea210d4a8a145 (patch)
treed89f0da1841b984c10a6a24997a8733524b75f75 /src/error.rs
parentb615f6e34e084d520dcc301058b5926074188500 (diff)
parent7876dd605a8e4b595436035a87a5151be187c01d (diff)
downloadwebol-ea4f36ea34a4e425ef23e2ae0d4ea210d4a8a145.tar
webol-ea4f36ea34a4e425ef23e2ae0d4ea210d4a8a145.tar.gz
webol-ea4f36ea34a4e425ef23e2ae0d4ea210d4a8a145.zip
Merge pull request #36 from FxQnLr/optional_ip
Optional ip and better docs
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!({