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

Make CoreSDKError Equatable #303

Merged
merged 9 commits into from
Nov 25, 2024
Merged

Make CoreSDKError Equatable #303

merged 9 commits into from
Nov 25, 2024

Conversation

KunJeongPark
Copy link
Collaborator

@KunJeongPark KunJeongPark commented Nov 22, 2024

Summary of changes

  • Make CoreSDKError Equatable and make static constants in CardError and PayPalError public so merchants can do this:
if let error {
  if error == CardError.threeDSecureCanceledError {
      // handle cancel case
   } else {
    // handle other errors 
 }

Checklist

  • Added a changelog entry

Authors

List GitHub usernames for everyone who contributed to this pull request.

@KunJeongPark KunJeongPark requested a review from a team as a code owner November 22, 2024 15:01
@KunJeongPark
Copy link
Collaborator Author

KunJeongPark commented Nov 22, 2024

I will also make other Error enums (eg. NetworkClientErrors) and static constants public.

I haven't seen a case where merchant needs to act on any error other than cancellation, but I think it's consistent to make all error types public.

@@ -47,7 +47,7 @@ class CardVaultViewModel: VaultViewModel {
)
)
} else if let vaultError {
if CardError.isThreeDSecureCanceled(vaultError) {
if let error = vaultError as? CoreSDKError, error == CardError.threeDSecureCanceledError {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q: is it possible to make vaultError a CoreSDKError? to prevent needing a cast here?

Copy link
Collaborator Author

@KunJeongPark KunJeongPark Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, good call. Actually, clientID fetching can also throw an error in the vault function above, so that's why I cast it here.

Copy link
Collaborator

@sshropshire sshropshire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome! 🔥

@KunJeongPark KunJeongPark merged commit c8c0ddf into main Nov 25, 2024
7 checks passed
@KunJeongPark KunJeongPark deleted the coreSDKError-equatable branch November 25, 2024 18:12
@KunJeongPark KunJeongPark mentioned this pull request Nov 25, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants