Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REFACTOR]: [NMI] Remove Default Case Handling #2276

Closed
2 tasks done
Sakilmostak opened this issue Sep 22, 2023 · 11 comments · Fixed by #2463
Closed
2 tasks done

[REFACTOR]: [NMI] Remove Default Case Handling #2276

Sakilmostak opened this issue Sep 22, 2023 · 11 comments · Fixed by #2463
Assignees
Labels
A-connector-integration Area: Connector integration C-feature Category: Feature request or enhancement good first issue Good for newcomers hacktoberfest Issues that are up for grabs for Hacktoberfest participants

Comments

@Sakilmostak
Copy link
Contributor

📝 Feature Description

  • We utilize match statements to make pivotal decisions, such as generating requests based on the payment method type and managing responses received from the connector.
  • These conditions generally go hand in hand with enum variants.
  • Default case is used because a match statement needs to be exhaustive i.e. every variant needs to be covered.
  • So, if all the explicit cases are handled then default is used to handle the rest.
  • Each connector have these match statements but many of them don’t provide reference to each variant in their default case, rather a _ is put to handle all the other cases.
  • This approach carries a risk because developers may inadvertently overlook the need for explicit handling of the new cases.

🔨 Possible Implementation

🔖 Note: All the changes needed should be contained within hyperswitch/crates/router/src/connector/

📦 Have you spent some time checking if this feature request has been raised before?

  • I checked and didn't find a similar issue

📦 Have you read the Contributing Guidelines?

✨ Are you willing to submit a PR?

@Sakilmostak Sakilmostak added A-connector-integration Area: Connector integration C-feature Category: Feature request or enhancement S-awaiting-triage Status: New issues that have not been assessed yet hacktoberfest Issues that are up for grabs for Hacktoberfest participants labels Sep 22, 2023
@VedantKhairnar VedantKhairnar added the good first issue Good for newcomers label Sep 28, 2023
@Cioraz
Copy link
Contributor

Cioraz commented Oct 4, 2023

Hey, Im interested in taking up this issue

@AkshayaFoiger AkshayaFoiger removed the S-awaiting-triage Status: New issues that have not been assessed yet label Oct 4, 2023
@AkshayaFoiger
Copy link
Contributor

Hey @Cioraz, sure! I've assigned this to you.

In case you have any queries, you can ask them on this issue thread, or on our discord server, or on slack whichever you are comfortable with

@Cioraz
Copy link
Contributor

Cioraz commented Oct 4, 2023

Just a follow up question,
The changes have to be made to line 120 in hyperswitch/crates/router/src/connector/nmi/transformer.rs in which I must match the errors for applepay and gpay.

image

And these the error changes for abandoned,cancelled,in_progress... fin lines 657

image

Am i right?

@AkshayaFoiger
Copy link
Contributor

AkshayaFoiger commented Oct 4, 2023

@Cioraz you are right! You have to make changes at line 120 and also line 115.
You have to match errors for all the unhandled variations of api_models::payments::WalletData and api::PaymentMethodData.

@Cioraz
Copy link
Contributor

Cioraz commented Oct 4, 2023

So Something like this would fix right?
Please correct me if im wrong as im still a beginner at rust

Screenshot from 2023-10-04 23-39-44

@AkshayaFoiger
Copy link
Contributor

AkshayaFoiger commented Oct 5, 2023

Hi @Cioraz,

You need to remove the default arm of the match statement and fill it with all possible values of WalletData. Your implementation is expected to be similar to

Screenshot 2023-10-05 at 12 35 36 PM

Here I have included a match arm for AliPayQr and AliPayRedirect. We expect you to fill all other match arms.
Note:To check for enum variants, do a command click on WalletData

Same implementation implies for line 120. Hope this answers you query.

@Cioraz
Copy link
Contributor

Cioraz commented Oct 5, 2023

Thanks a lot for the response will resolve it now

This was referenced Oct 5, 2023
@srujanchikke
Copy link
Contributor

Hey @Cioraz ,

We are glad you've raised a PR , May i know the reason why did you close the PR . We would be happy to help you out !

@Cioraz
Copy link
Contributor

Cioraz commented Oct 5, 2023

Sorry for the issue, i had forgotten to run cargo clippy to check so i just wanted to redo that, will soon raise another PR.

@Cioraz
Copy link
Contributor

Cioraz commented Oct 5, 2023

image
Could you help me with this when cargo building.

Below is the code
image

@srujanchikke
Copy link
Contributor

Sorry for the issue, i had forgotten to run cargo clippy to check so i just wanted to redo that, will soon raise another PR.

You can reopen the same pr and push more commits with working code .
Coming to the issue you're facing , use a double colon instead: :: after errors in line 140 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-connector-integration Area: Connector integration C-feature Category: Feature request or enhancement good first issue Good for newcomers hacktoberfest Issues that are up for grabs for Hacktoberfest participants
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants