Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ConnectError.unavailable when client is offline #328

Merged
merged 4 commits into from
Dec 31, 2024

Conversation

rebello95
Copy link
Collaborator

@rebello95 rebello95 commented Dec 23, 2024

Resolves #325.

When turning the device's wifi off, the following was observed with URLSession:

Before:

▿ Optional<ConnectError>
  ▿ some : ConnectError
    - code : Connect.Code.unknown
    ▿ message : Optional<String>
      - some : "The Internet connection appears to be offline."
    ▿ exception : Optional<Error>
      - some : Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." 

Based on the discussion in the issue linked above, this PR updates the code to be .unavailable:

▿ Optional<ConnectError>
  ▿ some : ConnectError
    - code : Connect.Code.unavailable
    ▿ message : Optional<String>
      - some : "The Internet connection appears to be offline."
    ▿ exception : Optional<Error>
      - some : Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." 

The NIO client has also been updated to return the .unavailable status code:

▿ Optional<ConnectError>
  ▿ some : ConnectError
    - code : Connect.Code.unavailable
    ▿ message : Optional<String>
      - some : "client is not connected"
    - exception : nil

@rebello95 rebello95 requested a review from jhump December 23, 2024 17:34
@rebello95 rebello95 changed the title Use unavailable ConnectError when URLSession is offline Use ConnectError.unavailable when URLSession is offline Dec 23, 2024
Signed-off-by: Michael Rebello <[email protected]>
@aheze
Copy link

aheze commented Dec 23, 2024

Btw does this work for NIOHttpClient?

@rebello95 rebello95 changed the title Use ConnectError.unavailable when URLSession is offline Use ConnectError.unavailable when client is offline Dec 27, 2024
@rebello95
Copy link
Collaborator Author

Btw does this work for NIOHttpClient?

I just updated the PR to handle both NIO and URLSession 👍🏽

@rebello95 rebello95 merged commit 20c7871 into main Dec 31, 2024
22 checks passed
@rebello95 rebello95 deleted the network-unavailable branch December 31, 2024 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No distinct error code for lack of internet access
3 participants