refactor(storage_models, errors): impl StorageErrorExt for error_stack::Result<T, errors::StorageError> (#886)

This commit is contained in:
Abhishek
2023-04-18 00:01:13 +05:30
committed by GitHub
parent 298a0a4956
commit b4020294cc
23 changed files with 125 additions and 268 deletions

View File

@ -865,19 +865,14 @@ pub async fn list_payments(
) -> RouterResponse<api::PaymentListResponse> {
use futures::stream::StreamExt;
use crate::types::transformers::ForeignFrom;
use crate::{core::errors::utils::StorageErrorExt, types::transformers::ForeignFrom};
helpers::validate_payment_list_request(&constraints)?;
let merchant_id = &merchant.merchant_id;
let payment_intents =
helpers::filter_by_constraints(db, &constraints, merchant_id, merchant.storage_scheme)
.await
.map_err(|err| {
errors::StorageErrorExt::to_not_found_response(
err,
errors::ApiErrorResponse::PaymentNotFound,
)
})?;
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
let pi = futures::stream::iter(payment_intents)
.filter_map(|pi| async {