Fix errors not matching PurchasesError - #579
Conversation
- Fix iOS to use 4-parameter reject() with error.info instead of error.error - Add TypeScript proxy layer to unwrap Capacitor's data field - Ensure error properties are accessible at top level on both platforms - Add logging to verify error unwrapping is working - Update README to reflect correct error structure Fixes: #302
ajpallares
left a comment
There was a problem hiding this comment.
I think it makes sense!
Should we add some unit tests for this?
Also, I'll leave approval to someone with more ts knowledge 🙏
tonidero
left a comment
There was a problem hiding this comment.
Just a question, but if we've tested it with most functions on the SDK in both Android and iOS, it does make sense. Thank you so much for handling this!!
| target: any, | ||
| methodName: string | symbol | ||
| ): T { | ||
| const wrappedFn = function(this: any, ...args: any[]) { |
There was a problem hiding this comment.
I'm wondering if we could apply a fix here so that, if any parameters are of type Vue.js reference (or maybe use something as a proxy, like the presence of a toRaw function, use that. In order to avoid these issues we've had with Vue.js reactivity... But in any case, that can come in a separate PR.
There was a problem hiding this comment.
Yeah, I have another branch for that, but since I am not quite sure how to test it. It's in another branch. Just opened the draft PR #583
| const value = Reflect.get(target, prop, receiver); | ||
|
|
||
| if (typeof value === 'function') { | ||
| if (typeof prop === 'number') { |
There was a problem hiding this comment.
Hmm I'm wondering is this ever the case? If i'm not wrong here, prop is the function name right?
There was a problem hiding this comment.
I think this can occur if a function gets called with index access [0], but I will double check
There was a problem hiding this comment.
we might be able to skip this tbh
This reverts commit 2d1c4cf.
|
I should check this still works fine with Capacitor 8 before merging |
We have this long standing issue #302 that reported that our errors don't match the typescript interface, particularly in iOS.
The main reason is that in Android, Capacitor automatically puts whatever is passed as the third parameter of the reject function in a
dataproperty in the error. In iOS, we were not even passing the user info, so the errors looked like this:Before the change
in Android:
in iOS:
After the change
in Android:
in iOS: