mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-09 22:35:56 +05:45
* Implemented initial HTTPRequestTimeoutManager + added first couple of tests * Cleaned up the code and added a bunch more unit tests based on the Android test suite * Updated doc format * Add new files to workspace * Added HTTPClient tests testing interaction with timeout manager * Swiftlint fixes * Updated comment * Add missing file to workspace * Fix after rebase * Added extra HTTPClient <-> HTTPRequestTimeoutManager tests asserting on the recorded events * Implemented PR feedback * Fixed compile issue * Fix compile issue * Implemented PR feedback * Removed deleted file reference from workspace * Fixed test after changing reset timeout * Make sure the default HTTPRequistTimeoutManager is using the default value from the HTTPClient * Add a sophisticated test testing the full timeout flow against an unroutable IP for a real world scenario * Updated timeout case name * Fixed case where .timeoutOnMainBackendForFallbackSupportedEndpoint was also recorded for non timeouts and added tests to prevent regression * Fixed only stubbing the HTTP response based on path, since that could be the same across hosts, resulting in flaky tests * Implemented tracking ConnectionErrorReason using DiagnosticsTracker on HTTP errors * Add new file to workspace * Updated string value of ConnectionErrorReason cases to match Android implementation * [skip ci] Generating new test snapshots (#5868) * [skip ci] Generating new test snapshots (#5869) * [skip ci] Generating new test snapshots (#5870) * [skip ci] Generating new test snapshots (#5871) * [skip ci] Generating new test snapshots (#5872) * [skip ci] Generating new test snapshots (#5874) * [skip ci] Generating new test snapshots (#5873) * Updated the list of URLError.code's that we consider a network error --------- Co-authored-by: RevenueCat Git Bot <72824662+RCGitBot@users.noreply.github.com>
53 lines
1.3 KiB
Swift
53 lines
1.3 KiB
Swift
//
|
|
// ConnectionErrorReason.swift
|
|
// RevenueCat
|
|
//
|
|
// Created by Rick van der Linden on 24/11/2025.
|
|
// Copyright © 2025 RevenueCat, Inc. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
enum ConnectionErrorReason: String, Codable {
|
|
case timeout = "TIMEOUT"
|
|
case noNetwork = "NO_NETWORK"
|
|
case other = "OTHER"
|
|
}
|
|
|
|
extension ConnectionErrorReason {
|
|
init(from error: NetworkError) {
|
|
switch error {
|
|
case let .networkError(networkError, _):
|
|
guard let urlError = networkError as? URLError else {
|
|
self = .other
|
|
return
|
|
}
|
|
|
|
switch urlError.code {
|
|
// Timeout error
|
|
case .timedOut:
|
|
self = .timeout
|
|
|
|
// Network connectivity errors
|
|
case .notConnectedToInternet,
|
|
.cannotConnectToHost,
|
|
.cannotFindHost,
|
|
.networkConnectionLost,
|
|
.dnsLookupFailed,
|
|
.internationalRoamingOff,
|
|
.callIsActive,
|
|
.dataNotAllowed:
|
|
self = .noNetwork
|
|
|
|
// Any other URLError.code
|
|
default:
|
|
self = .other
|
|
}
|
|
case .dnsError, .unexpectedResponse:
|
|
self = .noNetwork
|
|
default:
|
|
self = .other
|
|
}
|
|
}
|
|
}
|