summaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
authorFxQnLr <[email protected]>2024-02-18 21:16:46 +0100
committerFxQnLr <[email protected]>2024-02-18 21:16:46 +0100
commit2f9f18b80a9e2134f674f345e48a5f21de5efadd (patch)
treec4202bb5c1a490233e89d928cf8c5b91258d4c90 /src/error.rs
parent016fa3a31f8847d3f52800941b7f8fe5ef872240 (diff)
downloadwebol-2f9f18b80a9e2134f674f345e48a5f21de5efadd.tar
webol-2f9f18b80a9e2134f674f345e48a5f21de5efadd.tar.gz
webol-2f9f18b80a9e2134f674f345e48a5f21de5efadd.zip
Refactor stuff. Use Postgres Types
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/error.rs b/src/error.rs
index 63b214e..66a61f4 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -2,6 +2,8 @@ use axum::http::header::ToStrError;
2use axum::http::StatusCode; 2use axum::http::StatusCode;
3use axum::response::{IntoResponse, Response}; 3use axum::response::{IntoResponse, Response};
4use axum::Json; 4use axum::Json;
5use ::ipnetwork::IpNetworkError;
6use mac_address::MacParseError;
5use serde_json::json; 7use serde_json::json;
6use std::io; 8use std::io;
7use tracing::error; 9use tracing::error;
@@ -29,6 +31,18 @@ pub enum Error {
29 source: ToStrError, 31 source: ToStrError,
30 }, 32 },
31 33
34 #[error("string parse: {source}")]
35 IpParse {
36 #[from]
37 source: IpNetworkError,
38 },
39
40 #[error("mac parse: {source}")]
41 MacParse {
42 #[from]
43 source: MacParseError,
44 },
45
32 #[error("io: {source}")] 46 #[error("io: {source}")]
33 Io { 47 Io {
34 #[from] 48 #[from]
@@ -57,6 +71,14 @@ impl IntoResponse for Error {
57 error!("{source}"); 71 error!("{source}");
58 (StatusCode::INTERNAL_SERVER_ERROR, "Server Error") 72 (StatusCode::INTERNAL_SERVER_ERROR, "Server Error")
59 } 73 }
74 Self::MacParse { source } => {
75 error!("{source}");
76 (StatusCode::INTERNAL_SERVER_ERROR, "Server Error")
77 }
78 Self::IpParse { source } => {
79 error!("{source}");
80 (StatusCode::INTERNAL_SERVER_ERROR, "Server Error")
81 }
60 }; 82 };
61 let body = Json(json!({ 83 let body = Json(json!({
62 "error": error_message, 84 "error": error_message,