diff --git a/Sources/OfflineEntitlements/PurchasedProductsFetcher.swift b/Sources/OfflineEntitlements/PurchasedProductsFetcher.swift index fb3fa85d7f..18efedb4d6 100644 --- a/Sources/OfflineEntitlements/PurchasedProductsFetcher.swift +++ b/Sources/OfflineEntitlements/PurchasedProductsFetcher.swift @@ -60,11 +60,17 @@ class PurchasedProductsFetcher: PurchasedProductsFetcherType { } } - if result.isEmpty, let error = syncError { - // Only throw errors when syncing with the store if there were no entitlements found - throw error + if let error = syncError { + if result.isEmpty { + // Only throw errors when syncing with the store if there were no entitlements found + throw error + } else { + Logger.appleError(error.localizedDescription) + + // If there are any entitlements, ignore the error. + return result + } } else { - // If there are any entitlements, ignore the error. return result } } diff --git a/Tests/StoreKitUnitTests/OfflineEntitlements/PurchasedProductsFetcherTests.swift b/Tests/StoreKitUnitTests/OfflineEntitlements/PurchasedProductsFetcherTests.swift index e954b82ead..9de7c64c60 100644 --- a/Tests/StoreKitUnitTests/OfflineEntitlements/PurchasedProductsFetcherTests.swift +++ b/Tests/StoreKitUnitTests/OfflineEntitlements/PurchasedProductsFetcherTests.swift @@ -30,7 +30,7 @@ class BasePurchasedProductsFetcherTests: StoreKitConfigTestCase { self.sandboxDetector = MockSandboxEnvironmentDetector(isSandbox: .random()) self.fetcher = PurchasedProductsFetcher( - appStoreSync: self.syncAppStore, + appStoreSync: { try await self.syncAppStore() }, sandboxDetector: self.sandboxDetector ) } @@ -101,8 +101,8 @@ class FailingSyncPurchasedProductsFetcherTests: BasePurchasedProductsFetcherTest func testThrowsIfNoPurchasedProducts() async throws { do { - _ = try await self.fetcher.fetchPurchasedProducts() - fail("Expected error") + let result = try await self.fetcher.fetchPurchasedProducts() + fail("Expected error. Found \(result.count) products") } catch let error { expect(error).to(matchError(Self.error)) }