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

Network error returns NSError rather than regular Javascript error object #23

Closed
jasim opened this issue Aug 4, 2019 · 2 comments
Closed

Comments

@jasim
Copy link
Contributor

jasim commented Aug 4, 2019

To reproduce, run the plugin https://github.com/jasim/skpm_fetch_test with internet disabled.

Current error object

    Error Domain=NSURLErrorDomain 
    Code=-1009 "The Internet connection appears to be offline." 
    UserInfo={NSUnderlyingError=0x6000020738a0 
      {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" 
        UserInfo={_kCFStreamErrorCodeKey=50, _kCFStreamErrorDomainKey=1}},
    NSErrorFailingURLStringKey=https://example.com/invalid-url, 
    NSErrorFailingURLKey=https://example.com/invalid-url, 
    _kCFStreamErrorDomainKey=1, 
    _kCFStreamErrorCodeKey=50, 
    NSLocalizedDescription=The Internet connection appears to be offline.

Expected error object

    TypeError: "NetworkError when attempting to fetch resource."

To reproduce the error on the browser, open http://network-fetch-unavailable.surge.sh/, disconnect internet, and click the Run button. Check console log to see the error object.

See code at http://network-fetch-unavailable.surge.sh/script.js

@mathieudutour
Copy link
Member

So I don't have the same messages on Safari and Chrome:

  • Safari: TypeError: The Internet connection appears to be offline.
  • Chrome: TypeError: Failed to fetch

I'm guessing it'd be a lot easier to just re-use the message from the NSException which is the same on Safari

@mathieudutour
Copy link
Member

👍 Should be fixed in 0.5.0 (did a minor release because it might break existing scripts)

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

No branches or pull requests

2 participants