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]: [Braintree] Remove Default Case Handling #4058

Closed
2 tasks done
swangi-kumari opened this issue Mar 13, 2024 · 2 comments
Closed
2 tasks done

[REFACTOR]: [Braintree] Remove Default Case Handling #4058

swangi-kumari opened this issue Mar 13, 2024 · 2 comments
Labels
A-connector-integration Area: Connector integration C-refactor Category: Refactor help wanted Extra attention is needed

Comments

@swangi-kumari
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

  • Instead of relying on a default match case _, developers should handle each and every variant explicitly.
  • By doing so, if there are any changes in the future, they can readily assess the impact of their modifications simply by compiling the code.
  • In order to manage payment methods that are not implemented by Hyperswitch or yet to be implemented, the connector transformers file should make use of the NotImplemented ConnectorError enum variant.
  • By doing so, we will throw same error message for all the Connector Implementation
  • You can check this PR for further reference refactor(connector): [Zen] refactor Zen payment methods not implemented errors #1955

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

📦 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?

@swangi-kumari swangi-kumari added A-connector-integration Area: Connector integration C-refactor Category: Refactor help wanted Extra attention is needed labels Mar 13, 2024
@JamesM25
Copy link
Contributor

Hello,

I was hoping to open a pull request for this issue today, however I was not able to find any instances of the default match case _ in the transformers.rs file for Braintree.

If I am understanding this issue correctly, I believe it can be closed without any further changes, unless I am missing something?

@Sakilmostak
Copy link
Contributor

Hello @JamesM25 , It seems like there is no default cases available in this transformers, so you are correct. I will be closing this issue, sorry for the inconvenience. You can pick any of the similar issues, I will assign them to you.

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-refactor Category: Refactor help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants