summaryrefslogtreecommitdiff
path: root/server/src/errors.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/errors.rs')
-rw-r--r--server/src/errors.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/server/src/errors.rs b/server/src/errors.rs
index 72eb837..10c8f32 100644
--- a/server/src/errors.rs
+++ b/server/src/errors.rs
@@ -17,6 +17,8 @@ pub enum AppError {
TokenCreation,
/// Raised when a passed token is not valid
InvalidToken,
+ /// Raised if an user wants to do something can't do
+ Unauthorized,
}
/// Use `AppError` as response for an endpoint
@@ -39,6 +41,10 @@ impl IntoResponse for AppError {
"Token creation error".to_string(),
),
AppError::InvalidToken => (StatusCode::BAD_REQUEST, "Invalid token".to_string()),
+ AppError::Unauthorized => (
+ StatusCode::UNAUTHORIZED,
+ "Can't perform this action".to_string(),
+ ),
};
let body = Json(json!({