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

iOS error code passthrough #175

Merged
merged 2 commits into from
Mar 17, 2022
Merged

Conversation

dhenry-stripe
Copy link
Contributor

Addresses: #170

case .stripeAPIResponseDecodingError:
return "StripeAPIResponseDecodingError"
case .internalNetworkError:
return "InternalNetworkError"
Copy link
Contributor

Choose a reason for hiding this comment

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

oh huh, are going to have to manually maintain this and add new errors on every iOS release?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah... the enums are written in objective-c, which doesn't retain the name of the enum after compilation so there's no way to get the enum name

Copy link
Contributor

Choose a reason for hiding this comment

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

hrm, wonder if we can write a cross-repo code gen 🤔 (more of a long-term-nice-to-have)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can! At Netflix we used QuickType to generate types for Android, iOS, and TS: https://quicktype.io/

@@ -74,12 +74,12 @@ class StripeTerminalReactNative: RCTEventEmitter, DiscoveryDelegate, BluetoothRe
@objc(cancelCollectPaymentMethod:rejecter:)
func cancelCollectPaymentMethod(resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
guard let cancelable = collectPaymentMethodCancelable else {
resolve(Errors.createError(code: CommonErrorType.Failed.rawValue, message: "collectPaymentMethod could not be canceled because the command has already been canceled or has completed."))
resolve(Errors.createError(code: ErrorCode.cancelFailedAlreadyCompleted, message: "collectPaymentMethod could not be canceled because the command has already been canceled or has completed."))
Copy link
Contributor

Choose a reason for hiding this comment

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

just so I understand, do we not get pass through errors in some cases and have to generate our own?

Copy link
Contributor Author

@dhenry-stripe dhenry-stripe Mar 17, 2022

Choose a reason for hiding this comment

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

Yup, this case doesn't have a matching SDK error code. Android has TerminalException.TerminalErrorCode.INVALID_REQUIRED_PARAMETER but there's nothing equivalent in iOS. We could add one to the iOS SDK though and consume it here to remove the special case.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, let's log a ticket internally to track these, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dhenry-stripe dhenry-stripe merged commit 4ed53d2 into main Mar 17, 2022
arekkubaczkowski pushed a commit to arekkubaczkowski/stripe-terminal-react-native that referenced this pull request Jun 29, 2022
* Android cancellation error code fix

* iOS error codes passed through from SDK
@nazli-stripe nazli-stripe deleted the dhenry/ios-error-code-passthrough branch September 7, 2024 17:13
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