diff options
| author | Santo Cariotti <santo@dcariotti.me> | 2022-09-10 15:50:21 +0000 |
|---|---|---|
| committer | Santo Cariotti <santo@dcariotti.me> | 2022-09-10 15:50:21 +0000 |
| commit | 1666d757b87578eed22b4e1c67420c602554295a (patch) | |
| tree | 274ec6cd1041b2ca0a4c2b9f9c7cd23c4ce6638d /src | |
| parent | 2a90d0ff8d4336850a450f749140e2df2e94fc56 (diff) | |
Add `Unauthorized` error
Diffstat (limited to 'src')
| -rw-r--r-- | src/errors.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/errors.rs b/src/errors.rs index 2251ad4..e6f8e2c 100644 --- a/src/errors.rs +++ b/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!({ |
