summaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
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")