summaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
authorFxQnLr <[email protected]>2024-02-15 19:29:48 +0100
committerFxQnLr <[email protected]>2024-02-15 19:29:48 +0100
commit016fa3a31f8847d3f52800941b7f8fe5ef872240 (patch)
tree59bca278b082b0801c1a4174aac856be9ccd298f /src/error.rs
parent3bc7cf8ed36016ca3da9438a98f4fe8b8e6f9e61 (diff)
downloadwebol-016fa3a31f8847d3f52800941b7f8fe5ef872240.tar
webol-016fa3a31f8847d3f52800941b7f8fe5ef872240.tar.gz
webol-016fa3a31f8847d3f52800941b7f8fe5ef872240.zip
Closes #15. No usable Error message right now
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/error.rs b/src/error.rs
index 4f1bedd..63b214e 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -1,4 +1,4 @@
1use crate::auth::Error as AuthError; 1use 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;
@@ -11,12 +11,6 @@ pub enum Error {
11 #[error("generic error")] 11 #[error("generic error")]
12 Generic, 12 Generic,
13 13
14 #[error("auth: {source}")]
15 Auth {
16 #[from]
17 source: AuthError,
18 },
19
20 #[error("db: {source}")] 14 #[error("db: {source}")]
21 Db { 15 Db {
22 #[from] 16 #[from]
@@ -29,6 +23,12 @@ pub enum Error {
29 source: std::num::ParseIntError, 23 source: std::num::ParseIntError,
30 }, 24 },
31 25
26 #[error("header parse: {source}")]
27 ParseHeader {
28 #[from]
29 source: ToStrError,
30 },
31
32 #[error("io: {source}")] 32 #[error("io: {source}")]
33 Io { 33 Io {
34 #[from] 34 #[from]
@@ -40,7 +40,6 @@ impl IntoResponse for Error {
40 fn into_response(self) -> Response { 40 fn into_response(self) -> Response {
41 error!("{}", self.to_string()); 41 error!("{}", self.to_string());
42 let (status, error_message) = match self { 42 let (status, error_message) = match self {
43 Self::Auth { source } => source.get(),
44 Self::Generic => (StatusCode::INTERNAL_SERVER_ERROR, ""), 43 Self::Generic => (StatusCode::INTERNAL_SERVER_ERROR, ""),
45 Self::Db { source } => { 44 Self::Db { source } => {
46 error!("{source}"); 45 error!("{source}");
@@ -50,6 +49,10 @@ impl IntoResponse for Error {
50 error!("{source}"); 49 error!("{source}");
51 (StatusCode::INTERNAL_SERVER_ERROR, "Server Error") 50 (StatusCode::INTERNAL_SERVER_ERROR, "Server Error")
52 } 51 }
52 Self::ParseHeader { source } => {
53 error!("{source}");
54 (StatusCode::INTERNAL_SERVER_ERROR, "Server Error")
55 }
53 Self::ParseInt { source } => { 56 Self::ParseInt { source } => {
54 error!("{source}"); 57 error!("{source}");
55 (StatusCode::INTERNAL_SERVER_ERROR, "Server Error") 58 (StatusCode::INTERNAL_SERVER_ERROR, "Server Error")