mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-01 02:57:02 +08:00 
			
		
		
		
	chore: intoduce GenericError enum variant in enum ConnectorError (#6143)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
		| @ -0,0 +1,3 @@ | ||||
| --- | ||||
| openapi: get /v2/profiles/{profile_id}/connector_accounts | ||||
| --- | ||||
| @ -0,0 +1,3 @@ | ||||
| --- | ||||
| openapi: get /v2/merchant_accounts/{account_id}/profiles | ||||
| --- | ||||
| @ -46,7 +46,7 @@ | ||||
|         "api-reference/organization/organization--create", | ||||
|         "api-reference/organization/organization--retrieve", | ||||
|         "api-reference/organization/organization--update", | ||||
|         "api-reference/organization/merchant-account--list" | ||||
|         "api-reference/organization/organization--merchant-account--list" | ||||
|       ] | ||||
|     }, | ||||
|     { | ||||
|  | ||||
| @ -169,7 +169,7 @@ | ||||
|         "tags": [ | ||||
|           "Organization" | ||||
|         ], | ||||
|         "summary": "Merchant Account - List", | ||||
|         "summary": "Organization - Merchant Account - List", | ||||
|         "description": "List merchant accounts for an Organization", | ||||
|         "operationId": "List Merchant Accounts", | ||||
|         "parameters": [ | ||||
|  | ||||
| @ -119,6 +119,11 @@ pub enum ConnectorError { | ||||
|     InvalidConnectorConfig { config: &'static str }, | ||||
|     #[error("Failed to convert amount to required type")] | ||||
|     AmountConversionFailed, | ||||
|     #[error("Generic Error")] | ||||
|     GenericError { | ||||
|         error_message: String, | ||||
|         error_object: serde_json::Value, | ||||
|     }, | ||||
| } | ||||
|  | ||||
| impl ConnectorError { | ||||
|  | ||||
| @ -145,7 +145,7 @@ pub async fn organization_retrieve() {} | ||||
| pub async fn organization_update() {} | ||||
|  | ||||
| #[cfg(feature = "v2")] | ||||
| /// Merchant Account - List | ||||
| /// Organization - Merchant Account - List | ||||
| /// | ||||
| /// List merchant accounts for an Organization | ||||
| #[utoipa::path( | ||||
|  | ||||
| @ -218,7 +218,8 @@ impl<T> ConnectorErrorExt<T> for error_stack::Result<T, errors::ConnectorError> | ||||
|             | errors::ConnectorError::RequestTimeoutReceived | ||||
|             | errors::ConnectorError::CurrencyNotSupported { .. } | ||||
|             | errors::ConnectorError::InvalidConnectorConfig { .. } | ||||
|             | errors::ConnectorError::AmountConversionFailed { .. } => { | ||||
|             | errors::ConnectorError::AmountConversionFailed { .. } | ||||
|             | errors::ConnectorError::GenericError { .. } => { | ||||
|                 err.change_context(errors::ApiErrorResponse::RefundFailed { data: None }) | ||||
|             } | ||||
|         }) | ||||
| @ -314,6 +315,7 @@ impl<T> ConnectorErrorExt<T> for error_stack::Result<T, errors::ConnectorError> | ||||
|                 errors::ConnectorError::InSufficientBalanceInPaymentMethod | | ||||
|                 errors::ConnectorError::RequestTimeoutReceived | | ||||
|                 errors::ConnectorError::ProcessingStepFailed(None)| | ||||
|                 errors::ConnectorError::GenericError {..} | | ||||
|                 errors::ConnectorError::AmountConversionFailed => errors::ApiErrorResponse::InternalServerError | ||||
|             }; | ||||
|             err.change_context(error) | ||||
| @ -407,7 +409,8 @@ impl<T> ConnectorErrorExt<T> for error_stack::Result<T, errors::ConnectorError> | ||||
|                 | errors::ConnectorError::RequestTimeoutReceived | ||||
|                 | errors::ConnectorError::CurrencyNotSupported { .. } | ||||
|                 | errors::ConnectorError::ProcessingStepFailed(None) | ||||
|                 | errors::ConnectorError::AmountConversionFailed { .. } => { | ||||
|                 | errors::ConnectorError::AmountConversionFailed { .. } | ||||
|                 | errors::ConnectorError::GenericError { .. } => { | ||||
|                     logger::error!(%error,"Setup Mandate flow failed"); | ||||
|                     errors::ApiErrorResponse::PaymentAuthorizationFailed { data: None } | ||||
|                 } | ||||
|  | ||||
| @ -439,71 +439,6 @@ impl api::ConnectorCommon for ConnectorEnum { | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<T, ResourceCommonData, Req, Resp> api::ConnectorCommon | ||||
|     for ConnectorIntegrationEnum<'_, T, ResourceCommonData, Req, Resp> | ||||
| { | ||||
|     fn id(&self) -> &'static str { | ||||
|         match self { | ||||
|             ConnectorIntegrationEnum::Old(old_integration) => old_integration.id(), | ||||
|             ConnectorIntegrationEnum::New(new_integration) => new_integration.id(), | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     fn get_currency_unit(&self) -> CurrencyUnit { | ||||
|         match self { | ||||
|             ConnectorIntegrationEnum::Old(old_integration) => old_integration.get_currency_unit(), | ||||
|             ConnectorIntegrationEnum::New(new_integration) => new_integration.get_currency_unit(), | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     fn get_auth_header( | ||||
|         &self, | ||||
|         auth_type: &types::ConnectorAuthType, | ||||
|     ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> { | ||||
|         match self { | ||||
|             ConnectorIntegrationEnum::Old(old_integration) => { | ||||
|                 old_integration.get_auth_header(auth_type) | ||||
|             } | ||||
|             ConnectorIntegrationEnum::New(new_integration) => { | ||||
|                 new_integration.get_auth_header(auth_type) | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     fn common_get_content_type(&self) -> &'static str { | ||||
|         match self { | ||||
|             ConnectorIntegrationEnum::Old(old_integration) => { | ||||
|                 old_integration.common_get_content_type() | ||||
|             } | ||||
|             ConnectorIntegrationEnum::New(new_integration) => { | ||||
|                 new_integration.common_get_content_type() | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str { | ||||
|         match self { | ||||
|             ConnectorIntegrationEnum::Old(old_integration) => old_integration.base_url(connectors), | ||||
|             ConnectorIntegrationEnum::New(new_integration) => new_integration.base_url(connectors), | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     fn build_error_response( | ||||
|         &self, | ||||
|         res: types::Response, | ||||
|         event_builder: Option<&mut ConnectorEvent>, | ||||
|     ) -> CustomResult<types::ErrorResponse, errors::ConnectorError> { | ||||
|         match self { | ||||
|             ConnectorIntegrationEnum::Old(old_integration) => { | ||||
|                 old_integration.build_error_response(res, event_builder) | ||||
|             } | ||||
|             ConnectorIntegrationEnum::New(new_integration) => { | ||||
|                 new_integration.build_error_response(res, event_builder) | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| pub trait ConnectorIntegrationInterface<F, ResourceCommonData, Req, Resp>: Send + Sync { | ||||
|     fn clone_box( | ||||
|         &self, | ||||
|  | ||||
| @ -94,57 +94,37 @@ pub trait Router {} | ||||
| pub trait Connector: | ||||
|     Send | ||||
|     + Refund | ||||
|     + RefundV2 | ||||
|     + Payment | ||||
|     + PaymentV2 | ||||
|     + ConnectorRedirectResponse | ||||
|     + IncomingWebhook | ||||
|     + ConnectorAccessToken | ||||
|     + ConnectorAccessTokenV2 | ||||
|     + Dispute | ||||
|     + DisputeV2 | ||||
|     + FileUpload | ||||
|     + FileUploadV2 | ||||
|     + ConnectorTransactionId | ||||
|     + Payouts | ||||
|     + PayoutsV2 | ||||
|     + ConnectorVerifyWebhookSource | ||||
|     + ConnectorVerifyWebhookSourceV2 | ||||
|     + FraudCheck | ||||
|     + FraudCheckV2 | ||||
|     + ConnectorMandateRevoke | ||||
|     + ConnectorMandateRevokeV2 | ||||
|     + ExternalAuthentication | ||||
|     + ExternalAuthenticationV2 | ||||
|     + TaxCalculation | ||||
| { | ||||
| } | ||||
|  | ||||
| impl< | ||||
|         T: Refund | ||||
|             + RefundV2 | ||||
|             + Payment | ||||
|             + PaymentV2 | ||||
|             + ConnectorRedirectResponse | ||||
|             + Send | ||||
|             + IncomingWebhook | ||||
|             + ConnectorAccessToken | ||||
|             + ConnectorAccessTokenV2 | ||||
|             + Dispute | ||||
|             + DisputeV2 | ||||
|             + FileUpload | ||||
|             + FileUploadV2 | ||||
|             + ConnectorTransactionId | ||||
|             + Payouts | ||||
|             + PayoutsV2 | ||||
|             + ConnectorVerifyWebhookSource | ||||
|             + ConnectorVerifyWebhookSourceV2 | ||||
|             + FraudCheck | ||||
|             + FraudCheckV2 | ||||
|             + ConnectorMandateRevoke | ||||
|             + ConnectorMandateRevokeV2 | ||||
|             + ExternalAuthentication | ||||
|             + ExternalAuthenticationV2 | ||||
|             + TaxCalculation, | ||||
|     > Connector for T | ||||
| { | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Hrithikesh
					Hrithikesh