chore: send rest of the errors to the catchers

This commit is contained in:
Zomatree
2025-07-02 01:16:16 +01:00
parent cf4fe859bf
commit 46e127ccd2
8 changed files with 27 additions and 3 deletions

View File

@@ -38,6 +38,7 @@ impl<'r> FromRequest<'r> for User {
if let Some(user) = user {
Outcome::Success(user.clone())
} else {
request.local_cache(|| Some(create_error!(DuplicateNonce)));
Outcome::Error((Status::Unauthorized, authifier::Error::InvalidSession))
}
}

View File

@@ -113,6 +113,8 @@ impl<'r> FromRequest<'r> for IdempotencyKey {
let idempotency = IdempotencyKey { key };
let mut cache = TOKEN_CACHE.lock().await;
if cache.get(&idempotency.key).is_some() {
request.local_cache(|| Some(create_error!(DuplicateNonce)));
return Outcome::Error((Status::Conflict, create_error!(DuplicateNonce)));
}

View File

@@ -69,6 +69,7 @@ impl Error {
ErrorType::InvalidProperty => StatusCode::BAD_REQUEST,
ErrorType::InvalidSession => StatusCode::UNAUTHORIZED,
ErrorType::NotAuthenticated => StatusCode::UNAUTHORIZED,
ErrorType::Conflict => StatusCode::CONFLICT,
ErrorType::DuplicateNonce => StatusCode::CONFLICT,
ErrorType::VosoUnavailable => StatusCode::BAD_REQUEST,
ErrorType::NotFound => StatusCode::NOT_FOUND,

View File

@@ -152,6 +152,7 @@ pub enum ErrorType {
InvalidSession,
InvalidFlagValue,
NotAuthenticated,
Conflict,
DuplicateNonce,
NotFound,
NoEffect,
@@ -180,7 +181,7 @@ pub enum ErrorType {
// ? Feature flag disabled in the config
FeatureDisabled {
feature: String,
},
}
}
#[macro_export]

View File

@@ -76,6 +76,7 @@ impl Error {
ErrorType::InvalidProperty => Status::BadRequest,
ErrorType::InvalidSession => Status::Unauthorized,
ErrorType::NotAuthenticated => Status::Unauthorized,
ErrorType::Conflict => Status::Conflict,
ErrorType::DuplicateNonce => Status::Conflict,
ErrorType::VosoUnavailable => Status::BadRequest,
ErrorType::NotFound => Status::NotFound,