AdaptySDK-React-Native
AdaptySDK-React-Native copied to clipboard
adapty.getPaywall throws if paywall doesn't exist for id
Description
After migrating from v1 to v2 I realize that I can't easily implement a scenario where I check the case where no paywalls match the requested id. Before I could just do this:
const paywall = paywallsResponse.paywalls.find(
(p) => p.developerId === paywallId
);
if(!paywall){
// Do stuff
}
But now if I call adapty.getPaywall(paywallId)
with an invalid paywallId
it just throws, so I can't distinguish this specific case (the developer error, basically) from other cases.
The returned error is this, which is not very helpful:
{ [Error: #undefined (2004): Server error] adaptyCode: 2004, localizedDescription: 'Server error' }
I'm reporting this as a bug and not feature request since for me this is a regression in adapty sdk.
Version
v2.4.2
What platforms are you seeing the problem on?
iOS
System info
IDEs:
Xcode: 14.2/14C18 - /usr/bin/xcodebuild
npmPackages:
react: 18.1.0 => 18.1.0
react-native: 0.70.3 => 0.70.3
@amberv0 Hello again 👋 I'll discuss the possibility of adding 'not_found' error there today.
Since this is basically a network request, raising a 404 error (not the current one) seems valid to me, but you can try to coax me otherwise 👀
404 sounds correct to me.
For the end user of the sdk it might be better to have adapty.getPaywall()
return something like null
, but I might be wrong.