From 04fd5f6a158986bd60142415ebdd564b62ede1b5 Mon Sep 17 00:00:00 2001 From: Sarthak Soni Date: Thu, 20 Feb 2025 22:52:10 +0530 Subject: [PATCH] fix: Fixed more 5xx --- crates/router/src/core/routing/helpers.rs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/crates/router/src/core/routing/helpers.rs b/crates/router/src/core/routing/helpers.rs index e60e3fb42b9..318d7898f99 100644 --- a/crates/router/src/core/routing/helpers.rs +++ b/crates/router/src/core/routing/helpers.rs @@ -747,13 +747,17 @@ pub async fn push_metrics_with_update_window_for_success_based_routing( success_based_algo_ref .algorithm_id_with_timestamp .algorithm_id - .ok_or(errors::ApiErrorResponse::InternalServerError) + .ok_or(errors::ApiErrorResponse::GenericNotFoundError { + message: "success_rate algorithm_id not found".to_string(), + }) .attach_printable( "success_based_routing_algorithm_id not found in business_profile", )?, ) .await - .change_context(errors::ApiErrorResponse::InternalServerError) + .change_context(errors::ApiErrorResponse::GenericNotFoundError { + message: "success_rate based dynamic routing configs not found".to_string(), + }) .attach_printable("unable to retrieve success_rate based dynamic routing configs")?; let success_based_routing_config_params = dynamic_routing_config_params_interpolator @@ -984,13 +988,17 @@ pub async fn push_metrics_with_update_window_for_contract_based_routing( contract_routing_algo_ref .algorithm_id_with_timestamp .algorithm_id - .ok_or(errors::ApiErrorResponse::InternalServerError) + .ok_or(errors::ApiErrorResponse::GenericNotFoundError { + message: "contract_routing algorithm_id not found".to_string(), + }) .attach_printable( "contract_based_routing_algorithm_id not found in business_profile", )?, ) .await - .change_context(errors::ApiErrorResponse::InternalServerError) + .change_context(errors::ApiErrorResponse::GenericNotFoundError { + message: "contract based dynamic routing configs not found".to_string(), + }) .attach_printable("unable to retrieve contract based dynamic routing configs")?; let mut existing_label_info = None; @@ -1009,7 +1017,10 @@ pub async fn push_metrics_with_update_window_for_contract_based_routing( }); let final_label_info = existing_label_info - .ok_or(errors::ApiErrorResponse::InternalServerError) + .ok_or(errors::ApiErrorResponse::GenericNotFoundError { + message: "LabelInformation from ContractBasedRoutingConfig not found" + .to_string(), + }) .attach_printable( "unable to get LabelInformation from ContractBasedRoutingConfig", )?;