-
Notifications
You must be signed in to change notification settings - Fork 52
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
Conversation
case .stripeAPIResponseDecodingError: | ||
return "StripeAPIResponseDecodingError" | ||
case .internalNetworkError: | ||
return "InternalNetworkError" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.")) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Android cancellation error code fix * iOS error codes passed through from SDK
Addresses: #170