Skip to content

Commit

Permalink
Use unavailable ConnectError when URLSession is offline
Browse files Browse the repository at this point in the history
Resolves #325.

Signed-off-by: Michael Rebello <[email protected]>
  • Loading branch information
rebello95 committed Dec 23, 2024
1 parent a23beb7 commit acda3cf
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,15 @@ extension Code {
return .deadlineExceeded
case URLError.unsupportedURL.rawValue:
return .unimplemented
case NSURLErrorCannotConnectToHost,
NSURLErrorCannotFindHost,
NSURLErrorDataNotAllowed,
NSURLErrorInternationalRoamingOff,
NSURLErrorNetworkConnectionLost,
NSURLErrorNotConnectedToInternet,
NSURLErrorSecureConnectionFailed,
NSURLErrorTimedOut:
return .unavailable
case ...100: // URLSession can return errors in this range
return .unknown
default:
Expand Down

0 comments on commit acda3cf

Please sign in to comment.