chore: send rest of the errors to the catchers
This commit is contained in:
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user