build(deps): bump error-stack from version 0.3.1 to 0.4.1 (#4188)

This commit is contained in:
Sanchith Hegde
2024-04-01 12:31:17 +05:30
committed by GitHub
parent cb2000b088
commit ea730d4ffc
286 changed files with 1361 additions and 2397 deletions

View File

@ -14,7 +14,7 @@ use api_models::{
use common_utils::{
errors::ReportSwitchExt, events::ApiEventsType, ext_traits::Encode, request::RequestContent,
};
use error_stack::{report, IntoReport, ResultExt};
use error_stack::{report, ResultExt};
use masking::{ExposeInterface, Mask, PeekInterface, Secret};
use router_env::{
instrument,
@ -45,7 +45,7 @@ use crate::{
api::{self, mandates::MandateResponseExt},
domain::{self, types as domain_types},
storage::{self, enums},
transformers::{ForeignInto, ForeignTryInto},
transformers::{ForeignInto, ForeignTryFrom},
},
utils::{self as helper_utils, generate_id, OptionExt, ValueExt},
workflows::outgoing_webhook_retry,
@ -150,11 +150,9 @@ pub async fn payments_incoming_webhook_flow<Ctx: PaymentMethodRetrieve>(
error @ Err(_) => error?,
}
}
_ => Err(errors::ApiErrorResponse::WebhookProcessingFailure)
.into_report()
.attach_printable(
"Did not get payment id as object reference id in webhook payments flow",
)?,
_ => Err(errors::ApiErrorResponse::WebhookProcessingFailure).attach_printable(
"Did not get payment id as object reference id in webhook payments flow",
)?,
};
match payments_response {
@ -194,7 +192,6 @@ pub async fn payments_incoming_webhook_flow<Ctx: PaymentMethodRetrieve>(
}
_ => Err(errors::ApiErrorResponse::WebhookProcessingFailure)
.into_report()
.attach_printable("received non-json response from payments core")?,
}
}
@ -236,7 +233,6 @@ pub async fn refunds_incoming_webhook_flow(
.attach_printable("Failed to fetch the refund")?,
},
_ => Err(errors::ApiErrorResponse::WebhookProcessingFailure)
.into_report()
.attach_printable("received a non-refund id when processing refund webhooks")?,
};
let refund_id = refund.refund_id.to_owned();
@ -245,9 +241,7 @@ pub async fn refunds_incoming_webhook_flow(
let refund_update = storage::RefundUpdate::StatusUpdate {
connector_refund_id: None,
sent_to_gateway: true,
refund_status: event_type
.foreign_try_into()
.into_report()
refund_status: common_enums::RefundStatus::foreign_try_from(event_type)
.change_context(errors::ApiErrorResponse::WebhookProcessingFailure)
.attach_printable("failed refund status mapping from event type")?,
updated_by: merchant_account.storage_scheme.to_string(),
@ -335,7 +329,6 @@ pub async fn get_payment_attempt_from_object_reference_id(
.await
.to_not_found_response(errors::ApiErrorResponse::WebhookResourceNotFound),
_ => Err(errors::ApiErrorResponse::WebhookProcessingFailure)
.into_report()
.attach_printable("received a non-payment id for retrieving payment")?,
}
}
@ -361,9 +354,7 @@ pub async fn get_or_update_dispute_object(
amount: dispute_details.amount.clone(),
currency: dispute_details.currency,
dispute_stage: dispute_details.dispute_stage,
dispute_status: event_type
.foreign_try_into()
.into_report()
dispute_status: common_enums::DisputeStatus::foreign_try_from(event_type)
.change_context(errors::ApiErrorResponse::WebhookProcessingFailure)
.attach_printable("event type to dispute status mapping failed")?,
payment_id: payment_attempt.payment_id.to_owned(),
@ -391,9 +382,7 @@ pub async fn get_or_update_dispute_object(
Some(dispute) => {
logger::info!("Dispute Already exists, Updating the dispute details");
metrics::INCOMING_DISPUTE_WEBHOOK_UPDATE_RECORD_METRIC.add(&metrics::CONTEXT, 1, &[]);
let dispute_status: diesel_models::enums::DisputeStatus = event_type
.foreign_try_into()
.into_report()
let dispute_status = diesel_models::enums::DisputeStatus::foreign_try_from(event_type)
.change_context(errors::ApiErrorResponse::WebhookProcessingFailure)
.attach_printable("event type to dispute state conversion failure")?;
crate::core::utils::validate_dispute_stage_and_dispute_status(
@ -451,12 +440,9 @@ pub async fn mandates_incoming_webhook_flow(
.await
.to_not_found_response(errors::ApiErrorResponse::MandateNotFound)?,
_ => Err(errors::ApiErrorResponse::WebhookProcessingFailure)
.into_report()
.attach_printable("received a non-mandate id for retrieving mandate")?,
};
let mandate_status = event_type
.foreign_try_into()
.into_report()
let mandate_status = common_enums::MandateStatus::foreign_try_from(event_type)
.change_context(errors::ApiErrorResponse::WebhookProcessingFailure)
.attach_printable("event type to mandate status mapping failed")?;
let updated_mandate = db
@ -497,7 +483,9 @@ pub async fn mandates_incoming_webhook_flow(
})
} else {
logger::error!("Webhook source verification failed for mandates webhook flow");
Err(errors::ApiErrorResponse::WebhookAuthenticationFailed).into_report()
Err(report!(
errors::ApiErrorResponse::WebhookAuthenticationFailed
))
}
}
@ -567,7 +555,9 @@ pub async fn disputes_incoming_webhook_flow(
})
} else {
metrics::INCOMING_DISPUTE_WEBHOOK_SIGNATURE_FAILURE_METRIC.add(&metrics::CONTEXT, 1, &[]);
Err(errors::ApiErrorResponse::WebhookAuthenticationFailed).into_report()
Err(report!(
errors::ApiErrorResponse::WebhookAuthenticationFailed
))
}
}
@ -653,7 +643,6 @@ async fn bank_transfer_webhook_flow<Ctx: PaymentMethodRetrieve>(
}
_ => Err(errors::ApiErrorResponse::WebhookProcessingFailure)
.into_report()
.attach_printable("received non-json response from payments core")?,
}
}
@ -1108,7 +1097,7 @@ async fn trigger_webhook_to_merchant(
}
enums::WebhookDeliveryAttempt::ManualRetry => {
// Will be updated when manual retry is implemented
Err(errors::WebhooksFlowError::NotReceivedByMerchant).into_report()?
Err(errors::WebhooksFlowError::NotReceivedByMerchant)?
}
}
@ -1126,7 +1115,6 @@ fn raise_webhooks_analytics_event(
logger::error!(?error, "Failed to send webhook to merchant");
serde_json::to_value(error.current_context())
.into_report()
.change_context(errors::ApiErrorResponse::WebhookProcessingFailure)
.map_err(|error| {
logger::error!(?error, "Failed to serialize outgoing webhook error as JSON");
@ -1178,7 +1166,6 @@ pub async fn webhooks_wrapper<W: types::OutgoingWebhookType, Ctx: PaymentMethodR
let request_id = RequestId::extract(req)
.await
.into_report()
.attach_printable("Unable to extract request id from request")
.change_context(errors::ApiErrorResponse::InternalServerError)?;
let auth_type = auth::AuthenticationType::WebhookAuth {
@ -1190,7 +1177,6 @@ pub async fn webhooks_wrapper<W: types::OutgoingWebhookType, Ctx: PaymentMethodR
payment_id: webhooks_response_tracker.get_payment_id(),
};
let response_value = serde_json::to_value(&webhooks_response_tracker)
.into_report()
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Could not convert webhook effect to string")?;
@ -1341,7 +1327,6 @@ pub async fn webhooks_core<W: types::OutgoingWebhookType, Ctx: PaymentMethodRetr
.switch()
.attach_printable("Could not find object reference id in incoming webhook body")?;
let connector_enum = api_models::enums::Connector::from_str(&connector_name)
.into_report()
.change_context(errors::ApiErrorResponse::InvalidDataValue {
field_name: "connector",
})
@ -1431,7 +1416,6 @@ pub async fn webhooks_core<W: types::OutgoingWebhookType, Ctx: PaymentMethodRetr
let webhook_details = api::IncomingWebhookDetails {
object_reference_id: object_ref_id,
resource_object: serde_json::to_vec(&event_object)
.into_report()
.change_context(errors::ParsingError::EncodeError("byte-vec"))
.attach_printable("Unable to convert webhook payload to a value")
.change_context(errors::ApiErrorResponse::InternalServerError)
@ -1520,7 +1504,6 @@ pub async fn webhooks_core<W: types::OutgoingWebhookType, Ctx: PaymentMethodRetr
.attach_printable("Incoming webhook flow for mandates failed")?,
_ => Err(errors::ApiErrorResponse::InternalServerError)
.into_report()
.attach_printable("Unsupported Flow Type received in incoming webhooks")?,
}
} else {
@ -1542,7 +1525,6 @@ pub async fn webhooks_core<W: types::OutgoingWebhookType, Ctx: PaymentMethodRetr
let serialized_request = event_object
.masked_serialize()
.into_report()
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Could not convert webhook effect to string")?;
Ok((response, webhook_effect, serialized_request))
@ -1656,7 +1638,6 @@ pub async fn add_outgoing_webhook_retry_task_to_process_tracker(
.ok_or(errors::StorageError::ValueNotFound(
"Process tracker schedule time".into(), // Can raise a better error here
))
.into_report()
.attach_printable("Failed to obtain initial process tracker schedule time")?;
let tracking_data = types::OutgoingWebhookTrackingData {