Created
October 29, 2019 01:59
-
-
Save wotjd/2519902d4451a4c4fcd17ef0333db020 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Moya | |
import Foundation | |
guard let case MoyaError.underlying(nsError as NSError, _) = error else { return } | |
let unknownHostError = [ | |
NSURLErrorUnknown, | |
NSURLErrorCannotFindHost, | |
NSURLErrorDomain, | |
NSURLErrorCancelled, | |
NSURLErrorNetworkConnectionLost, | |
NSURLErrorNotConnectedToInternet, | |
NSURLErrorDNSLookupFailed, | |
NSURLErrorBackgroundSessionWasDisconnected, | |
NSURLErrorCancelledReasonBackgroundUpdatesDisabled, | |
NSURLErrorBackgroundSessionInUseByAnotherProcess | |
] | |
if unknownHostError.contains(nsError.code) { | |
print("unknown host error") | |
} else if nsError.code == NSURLErrorTimedOut { | |
print("timed out") | |
} else { | |
print("unhandled error") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment