refactor(payments): attempt to address unintended 5xx and 4xx in payments (#1376)

This commit is contained in:
Abhishek Marrivagu
2023-06-15 13:20:48 +05:30
committed by GitHub
parent 71c0d4c500
commit cf64862dac
4 changed files with 24 additions and 26 deletions

View File

@ -12,7 +12,7 @@ use crate::{
configs::settings,
core::{
api_keys,
errors::{self, RouterResult},
errors::{self, utils::StorageErrorExt, RouterResult},
},
db::StorageInterface,
routes::app::AppStateInfo,
@ -122,13 +122,7 @@ where
.store()
.find_merchant_account_by_merchant_id(&stored_api_key.merchant_id)
.await
.map_err(|e| {
if e.current_context().is_db_not_found() {
e.change_context(errors::ApiErrorResponse::Unauthorized)
} else {
e.change_context(errors::ApiErrorResponse::InternalServerError)
}
})
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)
}
}