-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
In one of our projects, we found ourselves often needing to identify networking errors, and so we've extended the error as such:
var isNetworkingError: Bool {
switch errorCode {
// NSURL Error Codes
case NSURLErrorCancelled, NSURLErrorTimedOut, NSURLErrorCannotFindHost, NSURLErrorCannotConnectToHost, NSURLErrorNetworkConnectionLost, NSURLErrorNotConnectedToInternet, NSURLErrorSecureConnectionFailed:
return true
// POSIX Error Codes
case Int(POSIXErrorCode.ECONNABORTED.rawValue), Int(POSIXErrorCode.ENETUNREACH.rawValue), Int(POSIXErrorCode.ECONNRESET.rawValue):
return true
default:
return false
}
}
This turned out to be quite useful, and maybe could be baked-in.
Metadata
Metadata
Assignees
Labels
No labels