Skip to content

Commit

Permalink
fix: offline directly after receive bad url error (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
sojingle authored Jan 31, 2025
1 parent bcd4a44 commit fb00966
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Sources/Amplitude/Utilities/EventPipeline.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public class EventPipeline {
self.currentUpload = nil
}
self.configuration.offline = true
self.logger?.log(message: "Request failed more than \(self.maxRetryCount) times, marking offline")
self.logger?.error(message: "Request failed more than \(self.maxRetryCount) times, marking offline")
} else {
// Don't send the next event file if we're being deallocated
let nextFileBlock: () -> Void = { [weak self] in
Expand All @@ -135,7 +135,7 @@ public class EventPipeline {
} else {
let sendingInterval = min(self.maxRetryInterval, pow(2, Double(failures - 1)))
self.uploadsQueue.asyncAfter(deadline: .now() + sendingInterval, execute: nextFileBlock)
self.logger?.debug(message: "Request failed \(failures) times, send next event file in \(sendingInterval) seconds")
self.logger?.error(message: "Request failed \(failures) times, send next event file in \(sendingInterval) seconds")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Amplitude/Utilities/HttpClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class HttpClient {
let nsError = error as NSError
if nsError.domain == NSURLErrorDomain {
switch nsError.code {
case NSURLErrorCannotConnectToHost, NSURLErrorNetworkConnectionLost, NSURLErrorCannotFindHost, NSURLErrorAppTransportSecurityRequiresSecureConnection, NSURLErrorNotConnectedToInternet:
case NSURLErrorCannotConnectToHost, NSURLErrorNetworkConnectionLost, NSURLErrorCannotFindHost, NSURLErrorAppTransportSecurityRequiresSecureConnection, NSURLErrorNotConnectedToInternet, NSURLErrorBadURL:
logger?.error(message: "Conection failed with error: \(error.localizedDescription), marking offline")
configuration.offline = true
default:
Expand Down

0 comments on commit fb00966

Please sign in to comment.