diff options
author | Santo Cariotti <santo@dcariotti.me> | 2022-08-22 16:06:28 +0200 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2022-08-22 16:06:28 +0200 |
commit | 14968097b28919f7e1f71ec5e49b30191826fa33 (patch) | |
tree | 1eda1c77577618491a7330ab2c67bca6f6c5139e /server/src/errors.rs | |
parent | 7c40a2f9ead877620ab74b5a5c35a70db1c94362 (diff) |
Sqlx connection
Diffstat (limited to 'server/src/errors.rs')
-rw-r--r-- | server/src/errors.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/server/src/errors.rs b/server/src/errors.rs index cf59d0c..dc0468e 100644 --- a/server/src/errors.rs +++ b/server/src/errors.rs @@ -7,6 +7,7 @@ use serde_json::json; pub enum AppError { Generic, + Database, } impl IntoResponse for AppError { @@ -16,6 +17,10 @@ impl IntoResponse for AppError { StatusCode::INTERNAL_SERVER_ERROR, "Generic error, can't find why", ), + AppError::Database => ( + StatusCode::INTERNAL_SERVER_ERROR, + "Error with database connection", + ), }; let body = Json(json!({ @@ -25,3 +30,9 @@ impl IntoResponse for AppError { (status, body).into_response() } } + +impl From<sqlx::Error> for AppError { + fn from(_error: sqlx::Error) -> AppError { + AppError::Database + } +} |