diff options
author | FxQnLr <[email protected]> | 2024-02-18 21:16:46 +0100 |
---|---|---|
committer | FxQnLr <[email protected]> | 2024-02-18 21:16:46 +0100 |
commit | 2f9f18b80a9e2134f674f345e48a5f21de5efadd (patch) | |
tree | c4202bb5c1a490233e89d928cf8c5b91258d4c90 /src/error.rs | |
parent | 016fa3a31f8847d3f52800941b7f8fe5ef872240 (diff) | |
download | webol-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.rs | 22 |
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; | |||
2 | use axum::http::StatusCode; | 2 | use axum::http::StatusCode; |
3 | use axum::response::{IntoResponse, Response}; | 3 | use axum::response::{IntoResponse, Response}; |
4 | use axum::Json; | 4 | use axum::Json; |
5 | use ::ipnetwork::IpNetworkError; | ||
6 | use mac_address::MacParseError; | ||
5 | use serde_json::json; | 7 | use serde_json::json; |
6 | use std::io; | 8 | use std::io; |
7 | use tracing::error; | 9 | use 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, |