Skip to content

[iOS]: Error is a localized description in the case of network timeout of lost connection #103

@CatchABus

Description

@CatchABus

In case of a timeout or lost connection error on legacy mode, client will return native instance in the case of android but a localized description in the case of iOS.
That is a problem when one wants to handle "connection offline" error and display a prompt.
The problem occurs in this line: https://github.com/nativescript-community/https/blob/master/src/https/request.ios.ts#L269

It would be more convenient if iOS returned the native error instance, just like android.
Ideally, one would be able to distinguish such an error (more or less) using a technique like the one below:

function isOfflineConnectionError(error): boolean {
  let isOffline: boolean;

  if (__ANDROID__) {
    isOffline = error instanceof java.net.UnknownHostException;
  } else {
    isOffline = error instanceof NSError && error.code === -1009;
  }

  return isOffline;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions