Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Commit

Permalink
Update isOffline(errorCode:) to catch additional NSURLErrors
Browse files Browse the repository at this point in the history
  • Loading branch information
jncosideout authored and teolemon committed Aug 19, 2020
1 parent 0548e69 commit d281d0a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Sources/Models/DataManagerHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,16 @@
import Foundation

func isOffline(errorCode: Int) -> Bool {
return errorCode == NSURLErrorNotConnectedToInternet || errorCode == NSURLErrorTimedOut
let offlineErrors = Set(
[NSURLErrorNotConnectedToInternet,
NSURLErrorTimedOut,
NSURLErrorCannotConnectToHost,
NSURLErrorCannotFindHost,
NSURLErrorNetworkConnectionLost,
NSURLErrorDNSLookupFailed,
NSURLErrorInternationalRoamingOff,
NSURLErrorCallIsActive,
NSURLErrorDataNotAllowed
])
return offlineErrors.contains(errorCode)
}

0 comments on commit d281d0a

Please sign in to comment.