diff options
Diffstat (limited to 'src/error.rs')
-rw-r--r-- | src/error.rs | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/src/error.rs b/src/error.rs index 1592a78..5b82534 100644 --- a/src/error.rs +++ b/src/error.rs | |||
@@ -1,4 +1,3 @@ | |||
1 | use std::error::Error; | ||
2 | use std::io; | 1 | use std::io; |
3 | use axum::http::StatusCode; | 2 | use axum::http::StatusCode; |
4 | use axum::Json; | 3 | use axum::Json; |
@@ -10,9 +9,7 @@ use crate::auth::AuthError; | |||
10 | #[derive(Debug)] | 9 | #[derive(Debug)] |
11 | pub enum WebolError { | 10 | pub enum WebolError { |
12 | Generic, | 11 | Generic, |
13 | // User(UserError), | ||
14 | Auth(AuthError), | 12 | Auth(AuthError), |
15 | Ping(surge_ping::SurgeError), | ||
16 | DB(sqlx::Error), | 13 | DB(sqlx::Error), |
17 | IpParse(<std::net::IpAddr as std::str::FromStr>::Err), | 14 | IpParse(<std::net::IpAddr as std::str::FromStr>::Err), |
18 | BufferParse(std::num::ParseIntError), | 15 | BufferParse(std::num::ParseIntError), |
@@ -22,13 +19,10 @@ pub enum WebolError { | |||
22 | impl IntoResponse for WebolError { | 19 | impl IntoResponse for WebolError { |
23 | fn into_response(self) -> Response { | 20 | fn into_response(self) -> Response { |
24 | let (status, error_message) = match self { | 21 | let (status, error_message) = match self { |
25 | Self::Auth(err) => err.get(), | 22 | Self::Auth(err) => { |
26 | // Self::User(err) => err.get(), | 23 | err.get() |
27 | Self::Generic => (StatusCode::INTERNAL_SERVER_ERROR, ""), | ||
28 | Self::Ping(err) => { | ||
29 | error!("Ping: {}", err.source().unwrap()); | ||
30 | (StatusCode::INTERNAL_SERVER_ERROR, "Server Error") | ||
31 | }, | 24 | }, |
25 | Self::Generic => (StatusCode::INTERNAL_SERVER_ERROR, ""), | ||
32 | Self::IpParse(err) => { | 26 | Self::IpParse(err) => { |
33 | error!("server error: {}", err.to_string()); | 27 | error!("server error: {}", err.to_string()); |
34 | (StatusCode::INTERNAL_SERVER_ERROR, "Server Error") | 28 | (StatusCode::INTERNAL_SERVER_ERROR, "Server Error") |
@@ -51,17 +45,4 @@ impl IntoResponse for WebolError { | |||
51 | })); | 45 | })); |
52 | (status, body).into_response() | 46 | (status, body).into_response() |
53 | } | 47 | } |
54 | } | 48 | } \ No newline at end of file |
55 | |||
56 | // #[derive(Debug)] | ||
57 | // pub enum UserError { | ||
58 | // UnknownUUID, | ||
59 | // } | ||
60 | // | ||
61 | // impl UserError { | ||
62 | // pub fn get(self) -> (StatusCode, &'static str) { | ||
63 | // match self { | ||
64 | // Self::UnknownUUID => (StatusCode::UNPROCESSABLE_ENTITY, "Unknown UUID"), | ||
65 | // } | ||
66 | // } | ||
67 | // } | ||